Angle between 2 points used to calculate light.
(Newbie - untextured 3D engine)
Isn''t there a formula to calculate the angle between to points with only sin, cos or tan?
I''m going to use this first to find the angle (for two spots in a polygon) then add 90 degrees to the result and then find the angle between the light spot and the result from before + the 90 degrees. Then find the distance and substract it from the above. Then fin % of the damn thing and calculate how dark a colour in my 3D object should be...
Can you give me any hints on doing this? Making light in an untextured 3D model?
Please don''t write strange coding language... I''m quite an idiot on that point. I''m having my own coding language, and I don''t think any of you know that...
Oh i think I found out...
To find the angle i can use this formula:
Tan-1( (Za - Zb) / (Xa - Xb) )
To find the angle i can use this formula:
Tan-1( (Za - Zb) / (Xa - Xb) )
Hi there,
in C ( I think math.h ) is a function called atan2 which computes the angle between the origin and a vector. The normal atan (Tan-1)may results in an ambigous angle
Good luck
in C ( I think math.h ) is a function called atan2 which computes the angle between the origin and a vector. The normal atan (Tan-1)may results in an ambigous angle
Good luck
Um, Andos, you''re describing cosine shading. If you have a polygonal surface and a light L whose direction is described by a vector, L.v, the magnitude of light incident on the surface is the dot product of the surface normal and the light direction.
%lighting = dotp( N, L.v );
The surface normal for a triangle can be determined as the cross product of the vectors describing two of its sides. Add one more cross product per additional polygon vertex.
N = crossp( (v2 - v1), (v2 - v3) );
normalize( N );
Done.
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
%lighting = dotp( N, L.v );
The surface normal for a triangle can be determined as the cross product of the vectors describing two of its sides. Add one more cross product per additional polygon vertex.
N = crossp( (v2 - v1), (v2 - v3) );
normalize( N );
Done.
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement