1. rotateing
- Posted by Hayden McKay <hmck1 at dodo.com.au> Mar 02, 2005
- 515 views
I'm looking for formulars to rotate 2d and 3d points arround an objects centre (x,y) (x,y,z) respectively. I've tried: deg/=100 new_x=(cos(deg)*x)-(sin(deg)*y) new_y=(sin(deg)*x)+(cos(deg)*y) seems to rotate O.K. but it's not what I'm looking for. ie: the origen here is assumed to be at 0:0. could some please point me in the right direction.
2. Re: rotateing
- Posted by Patrick Barnes <mrtrick at gmail.com> Mar 02, 2005
- 496 views
Ooh, matrices time. Know anything about matrices and matrix math? If not, I suggest you look for tutorials about them on the net. This one is good: http://chortle.ccsu.edu/VectorLessons/vectorIndex.html On Tue, 01 Mar 2005 20:27:48 -0800, Hayden McKay <guest at rapideuphoria.com> wrote: > > posted by: Hayden McKay <hmck1 at dodo.com.au> > > I'm looking for formulars to rotate 2d and 3d points arround an objects centre > (x,y) (x,y,z) respectively. > > I've tried: > deg/=100 > new_x=(cos(deg)*x)-(sin(deg)*y) > new_y=(sin(deg)*x)+(cos(deg)*y) > > seems to rotate O.K. but it's not what I'm looking for. > ie: the origen here is assumed to be at 0:0. > > could some please point me in the right direction. > > > > -- MrTrick
3. Re: rotateing
- Posted by Tommy Carlier <tommy.carlier at telenet.be> Mar 02, 2005
- 488 views
Hayden McKay wrote: > I'm looking for formulars to rotate 2d and 3d points arround an objects centre > (x,y) (x,y,z) respectively. > > I've tried: > deg/=100 > new_x=(cos(deg)*x)-(sin(deg)*y) > new_y=(sin(deg)*x)+(cos(deg)*y) > > seems to rotate O.K. but it's not what I'm looking for. > ie: the origen here is assumed to be at 0:0. > > could some please point me in the right direction. To rotate around a point, just subtract the coordinates from {x, y} before rotating, and add it again after rotating.
integer origin_x, origin_y, x, y, new_x, new_y atom deg ... deg /= 100 new_x = cos(deg) * (x - origin_x) - sin(deg) * (y - origin_y) + origin_x new_y = sin(deg) * (x - origin_x) + cos(deg) * (y - origin_y) + origin_y
-- The Internet combines the excitement of typing with the reliability of anonymous hearsay. tommy online: http://users.telenet.be/tommycarlier tommy.blog: http://tommycarlier.blogspot.com
4. Re: rotateing
- Posted by Hayden McKay <hmck1 at dodo.com.au> Mar 02, 2005
- 499 views
Ahh yes! thanks guys. Also there was another problem deg/=100 needed to be "deg*PI/180" ie: radans even though all the info I found on the internet used the word degrees. so I coded this
function make_cos() sequence s s=tabletype() for i=0 to 360 do s[i+1]=cos(i*PI/180) end for end function function make_sin() sequence s s=tabletype() for i=0 to 360 do s[i+1]=sin(i*PI/180) end for end function constant lookup_cos=make_cos() constant lookup_sin=make_sin()
I stress again thanks.. It should'nt be hard for me now to rotate a 3d coord arround an arbituary axis!
5. Re: rotateing
- Posted by Patrick Barnes <mrtrick at gmail.com> Mar 03, 2005
- 497 views
On Tue, 01 Mar 2005 22:51:14 -0800, Hayden McKay <guest at rapideuphoria.com> wrote: > I stress again thanks.. > It should'nt be hard for me now to rotate a 3d coord arround an arbituary > axis! Wait... 3d coords are much more difficult. With a 2d system, you just have a single number, 'angle'. With a 3d system, you either need to use a quarternion or a 3x3 rotation/scaling matrix. Sounds horrible, but I would recommend the 3x3 matrix as it's a lot faster, and you can set things up so it rotates and scales in the same step. -- MrTrick