Rectangles in 3d space
PhilipRBrenan@yahoo.com, 2004, Perl License
Example t/rectangle.t
#_ Rectangle __________________________________________________________ # Test 3d rectangles # philiprbrenan@yahoo.com, 2004, Perl License #______________________________________________________________________ use Math::Zap::Rectangle; use Math::Zap::Vector; use Test::Simple tests=>3; my ($a, $b, $c, $d) = (vector(0, 0, +1), vector(0, -1.9, -1), vector(0, -2.0, -1), vector(0, -2.1, -1) ); my $r = rectangle (vector(-1,-1, 0), vector( 2, 0, 0), vector( 0, 2, 0) ); ok($r->intersects($a, $b) == 1); ok($r->intersects($a, $c) == 1); ok($r->intersects($a, $d) == 0);
Create a rectangle from 3 vectors:
a position of any corner b first side c second side.
Note that vectors b,c must be at right angles to each other.
Create a rectangle from 3 vectors - synonym for "new".
Check its a rectangle
Test its a rectangle
Components of rectangle
Create a rectangle from another rectangle
Get/Set accuracy for comparisons
Intersect line between two vectors with plane defined by a rectangle
r rectangle a start vector b end vector
Solve the simultaneous equations of the plane defined by the rectangle and the line between the vectors:
ra+l*rb+m*rc = a+(b-a)*n =>ra+l*rb+m*rc+n*(a-b) = a-ra
Note: no checks (yet) for line parallel to plane.
# Test whether a line between two vectors intersects a rectangle # Note: no checks (yet) for line parallel to plane.
# Visibility of a rectangle r hid by other rectangles R from a view # point p. # Rectangle r is divided up into I*J sub rectangles: each sub rectangle # is tested for visibility from point p via the intervening rectangles.
# Project rectangle r onto rectangle R from a point p
# Project rectangle r into rectangle R from a point p
Export "rectangle"
philiprbrenan@yahoo.com
philiprbrenan@yahoo.com, 2004
Perl License.
To install Math::Zap::Draw, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::Zap::Draw
CPAN shell
perl -MCPAN -e shell install Math::Zap::Draw
For more information on module installation, please visit the detailed CPAN module installation guide.