Im writing a program in OpenGL/C++ to ray trace a cone.For my intensity calculations I need to know the surface normal.Given a base radius,height and centre coordinates,how do I calculate the surface normal?
Im writing a program in OpenGL/C++ to ray trace a cone.For my intensity calculations
Share
I am supposing that you need to find the normal to the surface given a point on the surface. I am further assuming that this is a cone oriented such that the base is facing down (-y axis) and the point of the cone points up (+y axis). If any of these conditions are not the case, I can edit my answer to fit your situation.
Let us call your point on the surface P, the center coordinates C, the radius r, the height h, and the normal N.
All points and vectors have three components (x, y, z), so I will refer to these by using a ".". For example P.x is the x component of P.
First, we need a unit vector projected on to the x/z plane which points from C to P.
This vector has the correct direction, but the magnitude is greater than one. It is not a unit vector yet, so we must scale it accordingly.
m is now the magnitude of V, which we will use to scale V:
The final calculations to find the normal are: