Macaulay2 » Documentation
Packages » VectorGraphics :: crossing
next | previous | forward | backward | up | index | toc

crossing -- Intersection of two lines

Synopsis

Description

Returns the location of the intersection of the two lines (p1,p2) and (q1,q2)

i1 : (a,b,c,d)=apply(1..4,i -> gNode([random RR,random RR],Circle{Radius=>0.05,"fill"=>"green","stroke"=>"black","stroke-width"=>0.01},Draggable=>true));
i2 : gList(Line{a,b},Line{c,d},Circle{crossing(a,b,c,d),Radius=>0.05,"fill"=>"blue"},a,b,c,d)

o2 = GraphicsList{cache => CacheTable{}                                                                                                                                                                                                    }
                  Contents => {Line{cache => CacheTable{}         }, Line{cache => CacheTable{}         }, Circle{cache => CacheTable{}                                                                                      }, a, b, c, d}
                                    Point1 => GraphicsCoordinate a        Point1 => GraphicsCoordinate c          Center => crossing (GraphicsCoordinate a, GraphicsCoordinate b, GraphicsCoordinate c, GraphicsCoordinate d)
                                    Point2 => GraphicsCoordinate b        Point2 => GraphicsCoordinate d          Radius => .05
                                    style => MutableHashTable{}           style => MutableHashTable{}             style => MutableHashTable{...1...}
                  style => MutableHashTable{}

o2 : GraphicsList

A more complex example: Pappus' theorem:

i3 : (ag,cg,Ag,Cg)=apply(([0,0],[100,0],[0,100],[100,100]),crd->Circle{Center=>crd,"draw"=>"black","fill"=>"red",Radius=>3,Draggable=>true});
i4 : (a,c,A,C)=apply((ag,cg,Ag,Cg),x->x.Center)

o4 = (a, c, A, C)

o4 : Sequence
i5 : b=a+1.2*c; B=1.7*A+C;
i7 : X=crossing(a,B,A,b); Y=crossing(a,C,A,c); Z=crossing(b,C,B,c);
i10 : (bg,Bg,Xg,Yg,Zg)=apply((b,B,X,Y,Z),crd->Circle{"fill"=>"black",Radius=>3,Center=>crd});
i11 : gList(Line{a,c},Line{A,C},Line{X,Z},Line{a,B},Line{a,C},Line{b,A},Line{b,C},Line{c,A},Line{c,B},
          ag,bg,cg,Ag,Bg,Cg,Xg,Yg,Zg,
          Margin=>.3)

o11 = GraphicsList{cache => CacheTable{}                                                                                                                                                                                                                                                                                                                                                      }
                   Contents => {Line{cache => CacheTable{}      }, Line{cache => CacheTable{}      }, Line{cache => CacheTable{}      }, Line{cache => CacheTable{}      }, Line{cache => CacheTable{}      }, Line{cache => CacheTable{}      }, Line{cache => CacheTable{}      }, Line{cache => CacheTable{}      }, Line{cache => CacheTable{}      }, ag, bg, cg, Ag, Bg, Cg, Xg, Yg, Zg}
                                     Point1 => a                        Point1 => A                        Point1 => X                        Point1 => a                        Point1 => a                        Point1 => b                        Point1 => b                        Point1 => c                        Point1 => c
                                     Point2 => c                        Point2 => C                        Point2 => Z                        Point2 => B                        Point2 => C                        Point2 => A                        Point2 => C                        Point2 => A                        Point2 => B
                                     style => MutableHashTable{}        style => MutableHashTable{}        style => MutableHashTable{}        style => MutableHashTable{}        style => MutableHashTable{}        style => MutableHashTable{}        style => MutableHashTable{}        style => MutableHashTable{}        style => MutableHashTable{}
                   Margin => .3
                   style => MutableHashTable{}

o11 : GraphicsList

Caveat

In 3d, the behavior is undetermined if the lines do not intersect.

For the programmer

The object crossing is a function closure.