trigonometry the solution to spinning image?
Blitz3D Forums/Blitz3D Programming/trigonometry the solution to spinning image?
| ||
how do I make an image rotate and spin around in the same place? I know you use cos() and sine. |
| ||
Are you using 3d commands or 2d commands? Do you want the image to rotate about its centre, or an arbitrary point in 2d? or 3d? space? |
| ||
2d and around it's centre. |
| ||
For real time usage it is better to 'precalculate' the rotations, ie rotate your image, and capture it as separate images for each angle.;to rotate about centre midhandle myimage ;change this to 0 or 1 to see the difference tformfilter 0 ;1 ;to rotate the image rotateimage myimage,angle# |
| ||
Yes, midhandle is the correct way to do this, but just for interest: To draw the image with its centre at (x#,y#): x= x-(ImageWidth(image)*cos(angle) + ImageHeight(image)*sin(angle))/2 y= y-(ImageWidth(image)*sin(angle) - ImageHeight(image)*cos(angle))/2 RotateImage image,angle DrawImage image,x,y (I've forgotten exactly how the b3d rotation commands work, but you get the idea) |
| ||
Sadly the 2D image rotations can be horribly slow, so doing 2D rotations in realtime is not really a good idea, depending on what you're trying to achieve. If RotateImage isn't fast enough, you could do a '2D in 3D' type thing where you use 3D commands to draw your image. |