3 D Geometry for Computer Graphics Class 1

















































- Slides: 49
3 D Geometry for Computer Graphics Class 1
General n Office hour: Tuesday 11: 00 – 12: 00 in Schreiber 002 (contact in advance) n Webpage with the slides, homework: http: //www. cs. tau. ac. il/~sorkine/courses/cg/cg 2006/ n E-mail: sorkine@tau. ac. il
The plan today n n Basic linear algebra and Analytical geometry
Why? ?
Manipulation of geometry and color… Monsters, Inc
Manipulation of geometry and color…
Manipulation of geometry and color…
Manipulation of geometry and color…
Manipulation of geometry and color…
Why? ? n We represent objects using mainly linear primitives: points ¨ lines, segments ¨ planes, polygons ¨ n Need to know how to compute distances, transformations, projections…
How to approach geometric problems n We have two ways: Employ our geometric intuition 2. Formalize everything and employ our algebra skills 1. n n Often we first do No. 1 and then solve with No. 2 For complex problems No. 1 is not always easy…
Example: distance between 2 lines in 3 D n Geometric problem: we have two lines (or segments) in 3 D, need to find the distance between them
Example: distance between 2 lines in 3 D n Geometric approach: ¨ If we look from the direction of one of the lines, that line reduces to a point ¨ So all we need is point-line distance in 2 D (the projection plane) ¨ By projecting, we reduced the problem from 3 D to 2 D
Example: distance between 2 lines in 3 D n Geometric approach: ¨ We can continue reducing the dimension! ¨ Project the red point and the blue line on the plane perpendicular to the blue line ¨ Now we get point-point distance
Example: distance between 2 lines in 3 D n But how do we get the actual number? ¨ Need n OK… ¨ Write n to represent the lines mathematically down the projection formulae Have to wipe the dust off our algebra… ¨ Compute n Easy the point-point distance
Example: distance between 2 lines in 3 D n Alternative: ¨ (Almost) skip the geometric intuition step… ¨ Represent the lines mathematically ¨ We know that the distance is achieved at a segment that is perpendicular to both lines ¨ Write down the equation for that segment and solve
Conclusion so far: n With or without geometric intuition and good 3 D orientation, in any case we need to review our algebra…
Basic definitions n n 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 B– A B A A– A B B
point + point: not defined!!
Map points to vectors n n If we have a coordinate system with origin at point O We can define correspondence between points and vectors: p O
Inner (dot) product n Defined for vectors: w L v Projection of w onto v
Dot product in coordinates (2 D) y yw yv O w v xw xv x
Perpendicular vectors In 2 D only: v v
Distance between two points y y. A A B y. B O x. A x. B x
Parametric equation of a line v t<0 p 0 t=0 t>0
Parametric equation of a ray v p 0 t=0 t>0
Distance between point and line q Find a point q’ such that (q q’) v dist(q, l) = || q q’ || l v p 0 q’ = p 0 +tv
Easy geometric interpretation q l v p 0 q’ L
Distance between point and line – also works in 3 D! n n The parametric representation of the line is coordinates-independent v and p 0 and the checked point q can be in 2 D or in 3 D or in any dimension…
Implicit equation of a line in 2 D y Ax+By+C > 0 Ax+ C By+ =0 Ax+By+C < 0 x
Line-segment intersection y Q 1 (x 1, y 1) Ax+By+C > 0 Q 2 (x 2, y 2) Ax+By+C < 0 x
Representation of a plane in 3 D space n n n A plane is defined by a normal n and one point in the plane p 0. A point q belongs to the plane < q – p 0 , n > = 0 The normal n is perpendicular to all vectors in the plane n q p 0
Distance between point and plane n Project the point onto the plane in the direction of the normal: dist(q, ) = ||q’ – q|| q q’ n p 0
Distance between point and plane q q’ n p 0
Distance between point and plane n Geometric way: ¨ Project (q - p 0) onto n! q n p 0
Implicit representation of planes in 3 D Ax+By+Cz+D > 0 n n (x, y, z) are coordinates of a point on Ax+By+Cz+D = the 0 plane (A, B, C) are the coordinates of a normal vector to the plane Ax+By+Cz+D < 0
Distance between two lines in 3 D q 1 l 1 p 1 u d l 2 q 2 v p 2 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
Distance between two lines in 3 D q 1 l 1 p 1 u d l 2 q 2 v p 2
Distance between two lines in 3 D q 1 l 1 p 1 u d l 2 q 2 v p 2
Distance between two lines in 3 D q 1 l 1 p 1 u d l 2 q 2 v p 2
Distance between two lines in 3 D n Exercise ( )תרגיל רשות : ¨ Develop the distance formula using the geometric intuition we talked about in the beginning of the class ¨ Compare to the formula we’ve just developed analytically
See you next time!
Barycentric coordinates (2 D) n n 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 C P A B
Barycentric coordinates (2 D) C P A B
Example of usage: warping
Example of usage: warping C Tagret A B We take the barycentric coordinates , , of P’ with respect to A’, B’, C’. Color(P) = Color( A + B + C)