2Dgeometry
Vectors,points,dotproduct
UpdatedSept2010
Coordinates,transformations
Lines,edges,intersections
Triangles
Circles
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 1
Motivation
The algorithms of Computer Graphics, Video Games,
and Digital Animations are about modeling and
processing geometric descriptions of shapes,
animations, and light paths.
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 2
Vectors(LinearAlgebra)
A vector is defined by a direction and a?
magnitude (also called norm or length)
A vector may be used to represent what?
displacement, force
What is a unit vector?
a vector with magnitude 1 (measured in chosen
unit)
What does a unit vector represent?
a direction (tangent, outward normal)
What is sV, where s is a scalar?
a vector with direction of V, but norm scaled by s
What is U+V?
the sum of the displacements of U and of V
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 3
Unaryvectoroperators
Definesadirection(anddisplacementmagnitude)
Usedtorepresentabasisvector,tangent,normal,force
Coordinates:V=<V.x,V.y>
Opposite:V=<V.x,V.y>
Norm(orlength,ormagnitude):n(V)=(V.x2+V.y2)
Nullvector:=<0,0>,n()=0
Scaling:sV=<sV.x,sV.y>,V/s=<V.x/s,V.y/s>
Direction(unitvector):U(V)=V/n(V,assumen(V)0
Rotated90degrees:R(V)=<V.y,V.x>
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 4
Binaryvectoroperators
Sum:U+V=<U.x+V.x,U.y+V.y>,
Difference:UV=<U.xV.x,U.yV.y>
Dotproduct(scalar):VU=U.xV.x+U.yV.y
Normsquared:V2=VV=(n(V))2
TangentialcomponentofVwrtU:VU=(VU)U/U2
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 5
DotProduct:Yourbestfriend
UV=||U||||V||cos(angle(U,V))
UVisascalar.
ifUandVareorthogonalthenUV==0
UV==0U==0orV==0or(UandVareorthogonal)
UVispositiveiftheanglebetweenUandVislessthan90 o
UV=VU,because:cos(a)=cos(a).
||u||=||v||=1uv=cos(angle(u,v) #unitvectors
Vu=signedlengthofprojectionofVontothedirection(unitvector)
cos(angle(u,v)) u VU=UV>0here VU=UV<0here
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 6
Dot product quiz
What does the dot product VU measure when U is unit?
The projected displacement of V onto U
What is VU equal to when U and V are unit?
cos( angle(U,V) )
What is VU equal to for general U and V?
cos( angle(U,V) ) n(V) n(U)
When is VU=0?
n(U)=0 OR n(V)=0 OR U and V are orthogonal
When is VU>0?
the angle between them is less than 90
How to compute VU?
U.xV.x+U.yV.y
What is V2?
V2 = VV = sq(n(V))
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 7
Anglesbetweenvectors
Polarcoordinatesofavector:(m=n(V),a=atan2(V.y,V.x))
a[,]
AssumeV0,U0
Anglebetweentwovectors:cos(a)=VU/(n(V)*n(U))
Usedifferencebetweenpolarcoordinatestosortvectorsbyangle
VandUareorthogonal(i.e.perpendicular)whenVU=0
V.xU.x + V.yU.y = 0
VandUareparallelwhenVR(U)=0
V.xU.y = V.yU.x
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 8
Application:Motionprediction
Basedonlast4positions,howtopredictthenextone?
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 9
Change of orthonormal basis
important!
A basis is two non-parallel vectors {I,J}
A basis is orthonormal is I2==1 and J=R(I)
What is the vector with coordinates <x,y> in basis
{I,J}?
xI+yJ
What is the vector <x,y> if we do not specify a
basis?
xX+yY, X is the horizontal, Y vertical unit vector
What are the coordinates <x,y> of V in orthonornal
basis (I,J)?
x=VI, y=VJ
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 10
Rotating a vector
What is the rotation (I,J) of basis (X,Y) by angle a?
(I,J) = ( < cos(a) , sin(a) > , < sin(a) , cos(a) > )
How to rotate vector <x,y> by angle a?
compute (I,J) as above, then compute xI+yJ
What are the coordinates of V rotated by angle a?
V.rotate(a) =
= V.x < cos(a) , sin(a) > + V.y < sin(a) , cos(a) >
= < cos(a) V.x sin(a) V.y , sin(a) V.x + cos(a) V.y >
What is the matrix form of this rotation?
( cos(a) V.x sin(a) V.y
sin(a) V.x + cos(a) V.y
cos(a)
sin(a) )(
=
sin(a)
)( )
cos(a)
V.x
V.y
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 11
Vector coordinates quiz
When are two vectors orthogonal (to each other)
When the angle between their directions is 90
What is an orthonormal basis?
two orthogonal unit vectors (I,J)
What is the vector with coordinates <V.x,V.y> in (I,J)?
V.x I + V.y J
What are the coordinates of vector combination
U+sV?
< U.x+sV.x, U.y+sV.y >
What is the norm of V?
n(V) = V.norm = sqrt( V.x2+V.y2 ) (always 0 )
What are the coordinates of V rotated by 90
R(V)= < V.y , V.x >, verify that VR(V) = 0
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 12
Radialcoordinatesandconversions
Whataretheradialcoordinates{r,a}ofV?
{ V.norm, atan2(V.y,V.x) }
WhataretheCartesiancoordinatesof{r,a}?
< r cos(a) , r sin(a) >
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 13
Reflection: used in collision and ray
tracing
Consider a line L with tangent direction T
What is the normal N to L?
N=R(T) N
What is the normal component of V? V2(VN)N
(VN)N (it is a vector)
What is the tangent component of V? V
2(VN)N
(VT)T
V
What is the reflection of V on L?
(VT)T(VN)N (reverse the normal component)
What is the reflection of V on L (simpler form not
using T)?
V2(VN)N (cancel, then subtract normal component)
This one works in 3D too (where T is not defined)
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 14
Applictionofreflection:Photontracing
Tracethepathofaphotonasitbouncesoffmirrorsurfaces(or
mirroredgesforaplanarversion)
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 15
Crossproduct:Yourotherbestfriend
ThecrossproductUVoftwovectorsisavectorthatis
orthogonaltoboth,UandVandhasformegnitudetheproductof
theirlengthsandofthesineoftheirangle
||UV||=||U||||V||sin(angle(U,V))
Hence,thecrossproductoftwovectorsintheplaneofthescreen
isavectororthogonaltothescreen.
OPERATOROVERLOADINGFOR2DCONSTRUCTIONS
Whendealingwith2Dconstructions,wedefineUVasascalar:
UV=||U||||V||sin(angle(U,V))
The2Dcrossproductisthezcomponentofthe3Dcrossproduct.
Verifythatin2D:UV=UR(V)
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 16
Changeofarbitrarybasis
What is the vector with coordinates <x,y> in basis
{I,J}?
xI+yJ
What are the coordinates <x,y> of V in basis (I,J)?
Solve V=xI+yJ,
a system of two linear equations with variables x and y
(two vectors are equal is their x and their y coordinates
are)
The solution (using Cramers rule):
x=VJ / IJ and y=VI / JI
Proof
V=xI+yJ VJ=xIJ+yJJ VJ=xIJ VJ / IJ=x
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 17
Points(AffineAlgebra)
Definealocation
CoordinatesP=(P.x,P.y)
GivenoriginO:PisdefinedbyvectorOP=PG=<P.x,P.y>
Subtraction:PQ=QP=<Q.xP.x,Q.yP.y>
Translation(addvector):Q=P+V=(P.x+V.x,P.y+V.y)
Incorrectbutconvenientnotation:
Average:(P+Q)/2=((P.x+Q.x)/2,(P.y+Q.y)/2)
correct form: P+PQ/2
Weighted average:wiPi, with wi =1
correctform: O+wjOPj
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 18
Practice with points
What does a point represent?
a location P+V
P V
What is P+V?
P translated by displacement V
What is the displacement from P to Q? Q
PQ
PQ = Q P ( vector ) P
What is the midpoint between P and Q?
P + 0.5PQ (also written P+PQ/2 or wrongly
(P+Q)/2 )
What is the center of mass G of triangle area (A,B,C)?
G=(A+B+C)/3, properly written G=A+(AB+AC)/3
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 19
vectorpoint
VectorsU,V,W PointsP,Q
Meaning displacement location
Translation forbidden P+V
Addition U+V forbidden
Subtraction W=UV V(=PQ)=QP
Dotproduct s=UV forbidden
Crossproduct W=UV forbidden
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 20
Orientatin and point-triangle
inclusion
When is the sequence A,B,C a left turn?
cw(A,B,C) = ABBC>0
(also =R(AB)BC>0 and also ABAC>0 )
When is triangle(A,B,C) cw (clockwise)?
cw(A,B,C)
When is point P in triangle(A,B,C)?
cw(A,B,P) == cw(B,C,P) && cw(A,B,P) ==
cw(C,A,P)
C cases:
Check all B C
P
P P
A A A
B C B
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 21
Edge intersection test
Linear parametric expression of the point P(s) on
edge(A,B)?
P(s) = A+sAB (also written (1s)A+sB ) for s in [0,1]
my Processing implementation is called L(A,s,B)
When do edge(A,B) and edge(C,D) intersect?
cw(A,B,C) != cw(A,B,D) ) && ( cw(C,D,A) !=
cw(C,D,B)
D
(special cases of collinear triplets require additional tests)
D
A B
C B
A
C
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 22
Normalprojectiononedge
WhendoestheprojectionQofpointPonltoLine(A,B)
fallbetweenAandB
i.e.:whendoesPprojectontoedge(A,B)?
when: P
0APABABAB A B
Q
orequivalently,when: P
0APAB&&0BPBA A B
Q
P
explainwhy:
A B
Q
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 23
PinE(point,edge):Pointinedgetest
WhenispointPinedge(a,b)?
when|abap|<||ab||&&abap>0&&babp>0
PROOF: p
q=projectionofpontotheline(a,b) a b
Thedistance||pq||fromptoqis q
|abap|/||ab|| p
Itneedstobelessthanathreshold a b
q
Wealsowanttheprojectionqtobe p
insideedge(a,b),hence: a b
abap>0&&babp>0 q
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 24
Parallellines
Whenareline(P,T)andline(Q,U)parallel
TU==0
orequivalentlywhen
TR(U)==0
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 25
Ray/line intersection
What is the expression of point on ray(S,T)?
P(t) = S+tT, ray starts at S and has tangent T
What is the constraint for point P to be on line(Q,N)?
QPN=0, normal component of vector QP is zero
What is the intersection X of ray(S,T) with line(Q,N)?
X = P(t) = S+tT, with t defined as the solution of
QP(t)N=0
How to compute parameter t for the intersection
above?
(P(t)Q)N=0
(S+tTQ)N=0
(QS+tT)N=0
QSN + tTN=0 , distributing over +
t = (QSN) / (TN)
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 26
Linesintersections
Twousefulrepresentationsofaline:
Parametricform,LineParametric(S,T): P(t)=S+tT
Implicit form, LineImplicit(Q,N): QPN=0
LineParametric(S,T) = LineImplicit(S,R(T))
Intersection: LineParametric(S,T) LineImplicit(Q,N)
SubstituteP(t)=S+tTforPintoQPN=0
Solvefortheparametervalue: t=(SQN)/(TN)
Substituteback:P(t)=S+(SQN)/(TN) T
Otherapproaches(solvelinearsystem):
S+tT==S+uTorQPN==0
QPN==0
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 27
Halfspace
LinearhalfspaceH(S,N)={P:SPN < 0 }
set of points P such that they are behind S with respect to N
N is the outward normal to the half-space
H(S,N) does not contain line {P:SPN==0 } (is topologically open)
L=line(S,T)(throughSwithtangentT)
L.right=H(S,R(T))
N=R(T) is the outward normal to the half-space
L.right is shown on the left in a Processing canvas (Y goes down)
L.right does not contain L (topologically open)
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 28
Transformations
Translation of P=(x,y) by vector V: TV(P) = P+V
Rotation : Ra(P) = ( x cos(a) y sin(a) , x sin(a) + y cos (a) )
by angle a around the origin
Composition: TV(Ra(P)), rotates by a, then translates by V
Translations commute: TU(TV(P))=TV(TU(P)) =TU+V(P)
2D rotations commute: Rb(Ra(P))=Ra(Rb(P))=Ra+b(P)
Rotations/translations do not commute: TV(Ra(P))Ra(TV(P))
Canonical representation of compositions of transformations:
Want to represent TW(Rc(TU(Rb(P)) as TV(Ra(P))
How to compute V and a?
How to apply it to points and vectors?
Answer: represent a composed transformation by a coordinate system
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 29
Coordinatesystem(frame)
Coordinatesystem[I,J,O]
O is the origin of the coordinate system (a translation vector)
{I,J} is an ortho-normal basis: I.norm=1, J=R(I)
{I,J} captures the rotation part of the transformation
Given local coordinates (x,y) of P in [I,J,O]
P=O+xI+yJ, start at O, move by x along I, move by y along J
Given P, O, I, J, compute (x,y)
x=OPI, y=OPJ
proof: OPI=xII+yJI=xII
For a vector V, no translation
Local coordinates <x,y>
Vector V = xI+yJ
Inverse: x=VI, y=VJ
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 30
RotationaroundcenterC
WhatistheresultPofrotatinapointPbyangleaaroundC?
RotatevectorCPandaddittoC
P=C+CP.rotate(a)
Hence:P=C+CP.x<cosa,sina>+CP.y<sina,cosa>
ThiscanbeexecutedinProcessing(andOpenGL)as3transforms:
TranslatebyCO(nowCisattheoriginandPisatO+CP)
Rotatebyanglea(rotatesCParoundorigin:O+CP.rotate(a))
TranslatebyOC(toputthingsback:O+CP.rotate(a)+OC)
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 31
A different (faster?) implementation
(cos(a) P.x sin(a) P.y, sin(a) P.x + cos (a) P.y)
may also be implemented as:
P.x = tan(a/2) P.y
P.y + = sin(a) P.x
P.x = tan(a/2) P.y
Which one is it faster to compute (this or the matrix
form)?
For animation, or to trace a circle:
pre-compute tan(a/2) and sin(a)
at each frame,
update P.x and P.y
add displacement OC if desired before rendering
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 32
Practice with Transforms
What is the translation of point P by displacement V?
P+V
What is the translation of vector U by displacement
V?
U (vectors do not change by translation)
What is the rotation (around origin) of point P by angle
a?
same as O + rotation of OP
(cos(a) P.x sin(a) P.y, sin(a) P.x + cos (a) P.y)
(
What is the matrix form of this rotation?
cos(a) P.x sin(a) P.y
sin(a) P.x + cos(a) P.y
cos(a)
sin(a)
sin(a)
cos(a)
)(
= )( )
P.x
P.y
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 33
Change of frame
Let (x1,y1) be the coordinates of P in [I1 J1 O1]
What are the coordinates (x2,y2) of P in [I2 J2 O2]?
P = O1+ x1 I1 +y1 J1 (convert local to global)
x2 = O2PI2 (convert global to local)
y2 = O2PJ2
Applications:
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 34
Whatisinarigidbodytransformmatrix?
Whydoweusehomogeneoustransforms?
Tobeabletorepresentthecumulativeeffectofrotations,
translations,(andscalings)intoasinglematrixform
WhatdothecolumnsofMrepresent?
AcanonicaltransformationTO(Ra(P))
O = <O.x,O.y> is the translation vector
[I,J] is the local basis (image of the global basis)
(I J) is a 22 rotation matrix: I.x = J.y = cos(a), I.y = J.x = sin(a)
a = atan2(I.y,I.x) is the rotation angle, with a[,]
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 35
Homogeneousmatrices
Representa2Dcoordinatesystembya33homogeneousmatrix
Transformpointsandvectorsthroughmatrixvectormultiplication
ForpointPwithlocalcoordinate(x,y)use<x,y,1>
ForvectorVwithlocalcoordinate<x,y>,use<x,y,0>
ComputingtheglobalcoordinatesofPfromlocal(x,y)ones
<P.x,P.y,1> = [I.h J.h O.h](x,y,1) = xI.h + yJ.h + O.h.
Vectorsarenotaffectedbyorigin(notranslation)
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 36
Invertingahomogeneousmatrix
The inverse of Ra is Ra
The inverse of a rotation matrix is its transpose
I.x = J.y = cos(a) remain unchanged since cos(a) = cos(a)
I.y = J.x = sin(a) change sign (swap places) since sin(a) = sin(a)
The inverse of TV is TV
The inverse of TV(Ra(P)) is Ra(TV(P))
It may also be computed directly as x=OPI, y=OPJ
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 37
Examplesofquestionsforquiz
Whatisthedotproduct<1,2><3,4>?
WhatisR(<1,2>)?
WhatisV2,whenV=<3,4>?
Whatistherotationby30ofpointParoundpointC?
Let(x1,y1)bethecoordinatesofpointPin[I1,J1,O1].How
wouldyoucomputeitscoordinates(x2,y2)in[I2,J2,O2]?(Donot
usematrices,butcombinationsofpointsandvectors.)
PointPwilltravelatconstantvelocityV.Whenwillithittheline
passingthroughQandtangenttoT?
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 38
Transformationsingraphicslibraries
translate(V.x,V.y); #implementTV(P)
rotate(a); #implementsRa(P)
translate(V.x,V.y);rotate(a); #implementsTV(Ra(P))
Noticelefttorightorder.ThinkofmovingglobalCS.
Scale(u,v); #implements(uP.x,vP.y)
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 39
Push/popoperators
{fill(red);paint();
translate(100,0);fill(green);paint();
rotate(PI/4);
fill(blue);paint();
translate(100,0);fill(cyan);paint();
scale(1.0,0.25);fill(yellow);paint();}
{fill(red);paint();
translate(100,0);fill(green);paint();
rotate(PI/4);
fill(blue);paint();
pushMatrix();
translate(100,0);fill(cyan);paint();
scale(1.0,0.25);fill(yellow);paint();
popMatrix();
translate(0,100);fill(cyan);paint();
scale(1.0,0.25);fill(yellow);paint();}
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 40
Circles and disks
How to identify all points P on circle(C,r) of center C
and radius r?
{ P : PC2=r2 }
How to identify all points P in disk(C,r)?
{ P : PC2r2 }
When do disk(C1,r1) and disk(C2,r2) interfere?
C1C22<(r1+r2)2
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 41
Circlesandintersections
Circleof center C and radius r, Circle(C,r): {P: CP2=r2}
where CP2 = CPCP
Diskof center C and radius r, Disk(C,r): {P: CP2<r2}
Disk(C1,r1) and Disk(C2,r2) interfere when (C1C2)2<(r1+r2)2
The intersection of LineParametric(S,T) with Circle(C,r):
Replace P in CP2 = r2 by S+tT
CP = PC = PStT = SPtT
(SPtT)( SPtT) = r2
(SPSP)2(SPT)t+(TT)t2 = r2
t22(SPT)t+(SP2r2)=0
Solve for t: real roots, t1 and t2, assume t1<t2
Points S+tT when t]t1,t2[ are in Disk(C,r)
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 42
Circumcenter
ptcenterCC(ptA,ptB,ptC){//circumcentertotriangle(A,B,C)
vecAB=A.vecTo(B);
floatab2=dot(AB,AB); 2ABAX=ABAB
vecAC=A.vecTo(C);AC.left();
floatac2=dot(AC,AC);
2ACAX=ACAC
floatd=2*dot(AB,AC);
AB.left();
AB.back();AB.mul(ac2); AB.left
AC.mul(ab2); C
AB.add(AC); AC.left
AB.div(d);
ptX=A.makeCopy(); AC
X.addVec(AB);
X
return(X);
}; A A AB B
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 43
Circles&spherestangenttoothers
Computecircletangentto3givenones
In3D,computespheretangentto4givenones.
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 44
Examplesofquestionsforquiz
WhatistheimplicitequationofcirclewithcenterCandradiusr?
Whatistheparametricequationofcircle(C,r)?
Howtotestwhetherapointisincircle(C.r)?
Howtotestwhetheranedgeintersectsacircle?
Howtocomputetheintersectionbetweenanedgeandacircle?
Howtotestwhethertwocirclesintersect?
Howtocomputetheintersectionoftwocircles
Assumethatdisk(C1,r1)startsatt=0andtravelswithconstant
velocityV.Whenwillitcollidewithastaticdisk(C2,r2)?
Assumethatadisk(C1,r1)arrivingwithvelocityVhasjustcollided
withdisk(C2,r2).ComputeitsnewvelocityV.
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 45
GeometryPractice
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 46
1)Pointonline
WhenisapointPonthelinepassingthroughpointQandhaving
unitnormalvectorN?
QPN=0,thevectorfromQtoapointonthelineisorthogonaltoN
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 47
2)Linearmotionofpoint
PointPstartsatSandmoveswithconstantvelocityV.Whereisit
afterttimeunits?
P(t)=S+tV,thedisplacementistime*velocity
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 48
3)Collision
WhenwillP(t)ofquestion2collidewiththelineofquestion1
linethroughQwithunitnormalvectorN
QP(t)=P(t)Q=S+tVQ=(SQ)+tV=QS+tV
(QS+tV)N=0,conditionforP(t)tobeontheline
Solvingfortbydistributingover+
t=(SQN)/(VN),noticethatSQ=QS
WhenVN=0:nocollision
Qmayalreadybeontheline
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 49
4)Intersection
ComputetheintersectionofalinethroughSwithtangentVwith
lineLthroughQwithnormalN.
Computet=(SQN)/(VN),asinthepreviousslideand
substitutethisexpressionfortinP=S+tV,yielding:
P=S+((SQN)/(VN))V
IfVN=0:nointersection
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 50
5)Medial
WhenisP(s)=S+tV,with|V|=1atthesamedistancefromSas
fromthelineLthroughQwithnormalN
Since|V|=1,P(t)hastraveledadistanceoftfromS.
ThedistancebetweenP(t)andthelinethroughQwithnormalNisQP(t) N
Hence,wehavetwoequations:P(t)=S+tVandQP(t) N=t
Solvefortbysubstitution:t=(QSN)/(1VN)
IfVN=0,useNinsteadofN
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 51
6)Point/linedistance
WhatisthedistancebetweenpointPandthelinethroughQwith
normalN
d=QPN,asusedinthepreviousquestion
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 52
7)Tangentcircle
ComputetheradiusrandcenterGofthecircletangentatStoa
linewithnormalVandtangenttoalinegoingthroughQwith
normalN
Fromquestion5:
r=(QSN)/(1VN)
WhenVN=0,useN
G=S+rV
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 53
8)Bisector
WhatisthebisectorofpointsAandB?
A B
Linethrough(A+B)/2
WithnormalN=AB.left.unit
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 54
9)Radius
Computetheradiusandcenterofthecirclepassingthroughthe3
points:A,B,andC
A S B
V
WecomputethebisectorsofABandBC t
Q C
andusetheresultofquestion3
S=(A+B)/2;V=BA.left.unit G
Q=(B+C)/2;N=BC.unit N
t=(SQN)/(VN)(fromquestion3)
G=S+tV
r=GB.unit
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 55
10)Distance
WhatisthesquaredistancebetweenpointsPandQ
PQPQ
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 56
11)Equidistant
LetP(t)=S+tV,with|V|=1.WhenwillP(t)beequidistantfrom
pointsSandQ?
Similarlytoquestiont,wehaveP(t)=S+tV
andwanttsuchthat(QP(t))2=t2
usingW2isWW
(QS+tV)(QS+tV)=t2
DistributingandusingVV=1permitstoeliminatet2
Solvingfort:
t=QS2/(2QSV)
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 57
12)Tangent
EstimatethetangentatBtothecurvethatinterpolatesthepolyloop
A,B,C
A C
AC.unit
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 58
13)Centerofcurvature
EstimatetheradiusrandcenterGofcurvatureatpointBthecurve
approximatedbythepolylinecontainingverticesA,B,C
N
B
BA BC
A V V C
D
Velocity:V=AC/2
BC
DN
Normal:N=V.left.unit
Acceleration:D=BA+BC
Normalacceleration:DN G
r=V2/D N
Thecenteroftheosculatingcircle
G=BrN
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 59
VectorformulaeforGin2Dand3D?
How to compute the center of curvature G in the
previous question
B
N
A C
V
V:= AC/2 ;
N:= BA + ((ABV)/(VV))
V;
G:= B + ((VV)/(2NN)) N ;
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 60
Practice: Circle/line intersection
When does line(P,T) intersect disk(C,r)?
|PC(T.left)| r
Where does line(S,T) intersect disk(C,r)?
CP = PC = PStT = SPtT
(SPtT)( SPtT) = r2
(SPSP)2(SPT)t+(TT)t2 = r2 (distribute over )
t22(SPT)t+(SP2r2)=0
Solve for t: real roots, t1 and t2, assume t1<t2
Points S+tT when t]t1,t2[ are in Disk(C,r)
Jarek Rossignac, 2010 www.gvu.gatech.edu/~jare 61