-
September 29th, 2011, 04:04 PM
#1
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.
-
October 3rd, 2011, 03:10 PM
#2
Re: rotating a point by x-axis is the formula valid for any theta
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?
-
October 5th, 2011, 02:53 AM
#3
Re: rotating a point by x-axis is the formula valid for any theta
Last edited by nuzzle; October 5th, 2011 at 03:23 AM.
-
October 5th, 2011, 03:16 AM
#4
Re: rotating a point by x-axis is the formula valid for any theta
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.
Last edited by nuzzle; October 5th, 2011 at 03:27 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|