Line2

Lines in 2d space

PhilipRBrenan@yahoo.com, 2004, Perl License

Synopsis

Example t/line2.t

 #_ Vector _____________________________________________________________
 # Test 2d lines    
 # philiprbrenan@yahoo.com, 2004, Perl License    
 #______________________________________________________________________
 
 use Math::Zap::Line2;
 use Math::Zap::Vector2;
 use Test::Simple tests=>12;
 
 my $x = vector2(1,0);
 my $y = vector2(0,1);
 my $c = vector2(0,0);
 
 my $a = line2( -$x,  +$x);
 my $b = line2( -$y,  +$y);
 my $B = line2(3*$y, 4*$y);
 
 ok($a->intersect($b) == $c);
 ok($b->intersect($a) == $c);
 ok($a->intersectWithin($b) == 1);
 ok($a->intersectWithin($B) == 0);
 ok($b->intersectWithin($a) == 1);
 ok($B->intersectWithin($a) == 1);
 ok($a->parallel($b) == 0);
 ok($B->parallel($b) == 1);
 ok(!$b->intersectWithin($B), 'Parallel intersection');
 ok( line2(-$x,       $x)->crossOver(line2(-$y,       $y)), 'Crosses 1');
 ok(!line2(-$x,       $x)->crossOver(line2( $y * 0.5, $y)), 'Crosses 2');
 ok(!line2( $x * 0.5, $x)->crossOver(line2( $y * 0.5, $y)), 'Crosses 3');
 

Description

Manipulate lines in 2D space

Constructors

new

Create a line from two vectors

line2

Create a line from two vectors

Methods

accuracy

Get/Set accuracy for comparisons

short

Short line?

check

Check its a line

is

Test its a line

a,b,ab,ba

Components of line

clone

Create a line from another line

print

Print line

angle

Angle between two lines

parallel

Are two lines parallel

intersect

Intersection of two lines

intersectWithin

Intersection of two lines occurs within second line?

crossOver

Do the two line segments cross over each other?

Exports

Export "line2"

Credits

Author

philiprbrenan@yahoo.com

philiprbrenan@yahoo.com, 2004

License

Perl License.