Computing the exit edge and intersection point of a Triangle:

advertisement
Sauvik Das
Project 5 Report
Computing the exit edge and intersection point of a Triangle:
In the code, upon entry into a triangle I am given the following: the corner, c, opposite
the edge of entry within the triangle, the point of entry and the direction of travel. To
calculate the exit edge, I use the following logic, the first part of which was already
implemented in the code for me:
1) Calculate the vector, N, that is normal to both the current triangle and the
direction of travel using a cross product.
2) Shoot a vector, V, from the point of entry to the corner c opposite the entry edge.
3) We know that since the corner c is opposite to the edge of entry, the edge of exit
must be one of the other two edges of the triangle, an endpoint of which must
include c. The task, then, is just to see whether the other endpoint is to the left or
right of vector V.
4) In order to figure out the question posed in 3, we dot V and N together. A positive
result means the exit edge is to the right, a negative to the left. Accordingly we set
the corner c to be the opposite of the exit edge.
5) The exit edge, now, is simple V(c.p, c.n).
To calculate the point of intersection given the exit edge, the direction or travel and the
point of entry, I use the following logic:
1) Parameterize the ray of travel into P=S+tD, where S is the point of entry and D is
the direction of travel
2) Find the vector normal to the current triangle and the edge of intersection using
cross product. Call the exit edge Q and the normal N. Given these two vectors, we
have an additional constraint that QP ∙ N = 0.
3) Plug in the expression for P in (1) into the expression in (2) to get: (S+tT-Q)∙N=0.
4) Simplify the above expression to: QS∙N+tT∙N=0
5) Solving for t, we get t=-(QS∙N)/( T∙N).
6) Plugging t back into the expression in one, we get the intersection point.
Computing the reflected direction D1 and the Normal vector between two triangles:
To compute the average normal vector of an edge between two triangles is actually quite
trivial. Given the normal of the two triangles defined in the code as t(c) and t(o(c))
(where t(c) is the current triangle and t(o(c)) is the next triangle), I simply call the
triNormal function to get the normals of each triangle. The triNormal function simply
crosses two edges of the triangle rooted at the same vertex(so ABxAC of triangle ABC). I
then make the normals of both these triangles unit, and then add the two unit normals
together. I then make the summed vector unit as well. This is the unit normal between
two triangles, which I will call N.
To calculate the direction of geodesic travel given the unit normal between two triangles
is simply a matter of subtraction. Our aim is to subtract the component of the given
direction, D, that lies along the normal of the two triangles twice from D. To do this, we
must first find the component of D that lies along N. This is simply the dot product of
these two vectors, D∙N. Now, we must simply subtract that dot product twice from D to
get the new direction: D-2(D∙N).
The definition of a geodesic path:
A geodesic path, as I understand it, is a path which would be a straight line if we were to
somehow find a way to map an entire surface(in this case a surface in three dimensions)
into a two dimensional plane.
Smoothing the normals:
In my implementation, I attempted to use a tuck(.2) to smooth the normals – that is, to
move each vertex one fifth of the way to the average of its neighbors. The results weren’t
great, and I believe this to be because of the nature of 3D surfaces. Due to discrepancies
of the vectors in the z-plane, simply moving towards the average of ones neighbors had
the nasty effect of causing the normals to merge into the surface itself (therefore not
really being normals anymore). Given the short amount of time and the relative
importance of this in the project, I didn’t implement a better strategy. Had I a bit more
time, I would have tried to trace the path created by neighboring normals, finding the
center of a common circle and try to move these normals as if they were all the radius of
this common circle. This would have helped preserve the general shape of the path while
likely producing a more aesthetically pleasing path.
Consecutive images of rolling:
When does this approach produce an animation that is not physically correct?
The proposed approach is, expectedly, not perfect. This imperfection is especially evident
when the coin attempts to roll across a sharp edge in an attempt to follow the contour of
the surface. In reality, when an object makes a sharp turn the likelihood of it following a
geodesic path is slim. Moreover, the animation entirely neglects other physical laws such
as gravity – rolling up a slope is just as acceptable as rolling down a slope. It also seems
like the approach ignores the local contour of the surface in that when the coin rolls on
the side of a slope, progressing straight forward without sliding down isn’t representative
of real world behavior.
Download