3D Geometry for Computer Graphics Class 1
General Office hour: Sunday 11:00 – 12:00 in Schreiber 002 (contact in advance) Webpage with the slides:
The plan today Basic linear algebra and Analytical geometry
Why??
We represent objects using mainly linear primitives: points lines, segments planes, polygons Need to know how to compute distances, transformations, projections…
Basic definitions Points specify location in space (or in the plane). Vectors have magnitude and direction (like velocity). Points Vectors
Point + vector = point
vector + vector = vector Parallelogram rule
point - point = vector A B B – A A B A – B
point + point: not defined!!
Map points to vectors If we have a coordinate system with origin at point O We can define correspondence between points and vectors:
Inner (dot) product Defined for vectors: L v w Projection of w onto v
Dot product in coordinates (2D) v w xvxv yvyv xwxw ywyw x y O
Perpendicular vectors (2D) v vv
Parametric equation of a line p0p0 v t > 0 t < 0 t = 0
Parametric equation of a ray p0p0 v t > 0 t = 0
Distance between two points B A xBxB yByB xAxA yAyA x y O
Distance between point and line Find a point q’ such that (q q’) v dist(q, l) = || q q’ || p0p0 v q q’ = p 0 +tv l
Easy geometric interpretation p0p0 v q q’ l L
Distance between point and line – also works in 3D! The parametric representation of the line is coordinates-independent v and p 0 and the checked point q can be in 2D or in 3D or in any dimension…
Implicit equation of a line in 2D x y Ax+By+C > 0 Ax+By+C < 0 Ax+By+C = 0
Line-segment intersection x y Ax+By+C > 0 Ax+By+C < 0 Q 1 (x 1, y 1 ) Q 2 (x 2, y 2 )
Representation of a plane in 3D space A plane is defined by a normal n and one point in the plane p 0. A point q belongs to the plane = 0 The normal n is perpendicular to all vectors in the plane n p0p0 q
Distance between point and plane Project the point onto the plane in the direction of the normal: dist(q, ) = ||q’ – q|| n p0p0 q’ q
Distance between point and plane n p0p0 q’ q
Implicit representation of planes in 3D (x, y, z) are coordinates of a point on the plane (A, B, C) are the coordinates of a normal vector to the plane Ax+By+Cz+D > 0 Ax+By+Cz+D < 0 Ax+By+Cz+D = 0
Distance between two lines in 3D p1p1 p2p2 u v d The distance is attained between two points q 1 and q 2 so that (q 1 – q 2 ) u and (q 1 – q 2 ) v q1q1 q2q2 l1l1 l2l2
Distance between two lines in 3D p1p1 p2p2 u v d q1q1 q2q2 l1l1 l2l2
p1p1 p2p2 u v d q1q1 q2q2 l1l1 l2l2
p1p1 p2p2 u v d q1q1 q2q2 l1l1 l2l2
Barycentric coordinates (2D) Define a point’s position relatively to some fixed points. P = A + B + C, where A, B, C are not on one line, and , , R. ( , , ) are called Barycentric coordinates of P with respect to A, B, C (unique!) If P is inside the triangle, then + + =1, , , > 0 A B C P
Barycentric coordinates (2D) A B C P
Example of usage: warping
Tagret A B C We take the barycentric coordinates , , of P’ with respect to A’, B’, C’. Color( P ) = Color( A + B + C )
See you next time!