rotating a point by x-axis is the formula valid for any theta
Dear Friends
I am trying to sweep a set of points by some degree theta. So I am using this formula
newx = x;
newy = y * cos(theta) - z * sin(theta);
newz = y * sin(theta) + z * cos(theta);
Is this formula valid for any degree theta.
Because when theta=360 degree, then sin(theta) = 1.47e--05
Is this okay. Please give me some idea.
Re: rotating a point by x-axis is the formula valid for any theta
Quote:
Originally Posted by
sujan.dasmahapatra
Because when theta=360 degree, then sin(theta) = 1.47e--05
Floating point operations are never mathematically exact. You expected an answer of zero, but instead got 1.47e-05, which is probably within expected errors for floating point operations.
How close to zero do you need it to be?
Re: rotating a point by x-axis is the formula valid for any theta
Re: rotating a point by x-axis is the formula valid for any theta
Quote:
Originally Posted by
sujan.dasmahapatra
Is this okay. Please give me some idea.
You should get 0.0 for sin(2.0*PI).
Maybe you aren't specifying PI with enougth precision (digits). You can try this,
const double PI = 3.141592653589793238;
Also if you're using floats try double throughout. If you're using doubles already make sure you don't have a narrowing conversion to float somewhere.
Or maybe you simply are specifying theta in degrees while sin() expects radians.