Math::Project3D::Function - Generate anonymous subroutines for use as functions with Math::Project3D
use Math::Project3D; # Looks like a screw my $function = Math::Project3D->new_function( 'u,v', # list of parameter names '$u', # first component 'sin($v)', # more components 'cos($v)', ); # or as an anonymous sub / closure! { # This is a sphere my $radius = 5; my $x_component = sub { my $theta = shift; my $phi = shift; return $radius * sin($theta) * cos($phi); }; my $y_component = sub { my $theta = shift; my $phi = shift; return $radius * sin($theta) * sin($phi); }; my $z_component = sub { my $theta = shift; return $radius * cos($theta); }; $function = Math::Project3D->new_function( $x_component, $y_component, $z_component ); }
This package contains the code for generating anonymous subroutines for use as functions with the Math::Project3D module. The package has no public subroutines and you should use it indirectly through the new_function method of Math::Project3D.
new_function
Oh, yes, I almost forgot. Do not read the source. :-)
Public methods
The new method takes exactly the same arguments as the new_function method of Math::Project3D.
new
It returns a new Math::Project3D::Function object.
Steffen Mueller, mail at steffen-mueller dot net
Copyright (c) 2002-2006 Steffen Mueller. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Math::Project3D
To install Math::Project3D, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::Project3D
CPAN shell
perl -MCPAN -e shell install Math::Project3D
For more information on module installation, please visit the detailed CPAN module installation guide.