Professional Documents
Culture Documents
Contents
o Geometry (2D, 3D)
o Trigonometry
o Vector spaces
n Points, vectors, and coordinates
o Dot and cross products
o Linear transforms and matrices
Y
Y
x = x1 + t(x2-x1)
y = y1 + t(y2-y1) y t >1
P = (x, y)
t<0, before P1(x1, y1)
t=1 P2 = (x2, y2)
t=0, P=P1
0<t<1, get points 0< t <1
between P1 and P2
t=1, P=P2(x2, y2) t=0 P1 = (x1, y1)
t>1, after P2 t<0
x
Elements of Computer Assisted Graphics 5
Line related formulas
o Length = sqrt (x2 - x1)2 + (y2 - y1)2
o Midpoint, p3, between p1 and p2
p3 = ((x1 + x2) / 2, (y1 + y2) / 2))
o Two lines are perpendicular if:
m1 = -1/m2
cos(θ) = 0
dot product of related vectors is zero (u•v=0)
o Point P3 lays on the line P1P2 if:
Cartesian space, slope based definition:
y3 = mx3 + b, where m(P1,P2), b(P1,P2)
Affine space, parametric definition:
P3 = P1 + t(P2-P1), the system of equation on x, y (and z)
should have solution. The position depends on the t value
(<0, 0, 0..1, 1, 1<)
ux x
y y
u+v
v v
u u
x -v x
u-v
o Used for:
n Computing the length (Euclidean Norm) of a vector:
length(v) = ||v|| = sqrt(v • v)
n Computing the distance between two points P and Q:
v = Q – P, distance(P, Q) = length(v) = ||v|| = sqrt(v • v)
n Normalizing a vector, making it unit-length: v = v / ||v||
n Checking two vectors for orthogonality
u•v=0
n θ
v Q
P
u•v
_________
||w||=||u||cos(θ)=||u|| = u•v
||u||·||v||
u
n θ
θ v Q
P
w v
x1 x2 i j k i j k
v1 = y1 v2 = y2 v = v1xv2 = x1 y1 z1 v = x1 0 0
z1 z2 x2 y2 z2 0 y2 0
v2 y1 z2 – y2 z1 0
n3 v8 v7
v8 v7
v4 v3
n3
v4
v3 n2
n2
v6 n1 v6
v1 v2
n1 v1 v2
(x1, y1)
v = v1xv2 = x1 y1 0
x2 y2 0 v1
x
v
v = (x1 y2 – x2 y1) k
The cross product is a vector v along z, z
of module | x1 y2 – x2 y1|.
y C (x2, y2)
v2
B
θ (x1, y1)
v1
A
x
Elements of Computer Assisted Graphics 14
Area of a triangle
The triangle ABC has the area:
½ (x1-x2) (y1+y2) + y C (x2, y2)
½ (x2-x0) (y2+y0) +
½ (x0-x1) (y0+y1) = v2 (x1, y1)
B
½ (x1y1+x1y2-x2y1-x2y2 +
θ
x2y2+x2y0-x0y2-x0y0 + v1
x0y0+x0y1-x1y0-x1y1) = A
(x0, y0)
x
½ (x0y1-x1y0+x1y2-x2y1+x2y0-x0y2)
where x0, y0 = 0
S = ½ (x1y2-x2y1)
therefore
S = ½ |v1 x v2|
Moreover
v1x v2 = |v1| |v2| sinθ
u
c
v
n
a
n-1
O x
S = 1/2 Σi=0
(xiyi+1 – xi+1yi)
n-1
Pn-1
S = 1/2 Σi=0
(vi x vi+1)
(xn-1, yn-1) (x1, y1)
P1
P0
(x0, y0)
O x
E E
D
D B
B C
A
A
E E
D
D B
B C
P0
x
O
y1 z1 1 x1 z1 1
x y z 1 A= y2 z2 1 B=- x2 z2 1
x1 y1 z1 1 y3 z3 1 x3 z3 1
=0
x2 y2 z2 1
x3 y3 z3 1 x1 y1 1 x1 y1 z1
C= x2 y2 1 D=- x2 y2 z2
x3 y3 1 x3 y3 z3
((P - Q)•v
__________
Gives t=
w•v
((P - Q)•v
And the intersection point is Q+ _________ w
w•v
x1 y1 1
D = x2 y2 1
x3 y3 1 Q = (x2, y2) R = (x3, y3)
t=1
Discussion on the t: P2 = (x2, y2)
t=0, P=P1(x1, y1) 0< t <1
t=1, P=P2(x2, y2)
0<t<1, the P position t=0 P1 = (x1, y1)
between P1 and P2
t<0
P
B C
B
C
P
A A
P3
E E
5 D D P2
4
P1
1
P 3 P
2
B B
C C
B
C
A
A
E
E
D
D
B
B C
C
Q Q Q
n n n
P P
P
Г Г Г
If t = 0 then L(t) = L0
If t = 1 then L(t) = L1
Otherwise, L(t) is part way from L0 to L1
(L(t) - Q) • n = 0
(L0 + (L1 - L0)t – Q) • n = 0
t = [(Q - L0) • n] / [(L1 - L0) • n]
E1 L1
P Q E2
B
n
C
Elements of Computer Assisted Graphics 38
Line to polygon relationship
o Convex and concave polygons
o Triangulation
o Convex polygons
n Analyses the line to edges relationships
n Cyrus-Beck algorithm
(requires a convex polygon!)
D
E1 L3
Q E2 L1 E3
P B
E
P5
P3
Cyrus-Beck algorithm:
P5
P3
Cyrus-Beck algorithm:
P P
6
R
A
1 5
Q
0 P
B
C
2
3
4