VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Rotation of points in 3D

by Nick Thompson (6 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

This code rotates a point around another in 3D using simple fast code. It does this using x, y, z coordinates, cosine and sine. It is 100% accurate.

Inputs
oldx oldy oldz (coordinates) angle (angle of rotation in radians)
Assumes
A good grasp of maths is a good idea
Code Returns
newx newy newz (new, rotated coordinates)
Side Effects
Definately no side effects

Rate Rotation of points in 3D

'For best results define variables as doubles
'The angle of rotation is in Radians, view this in
'your VB help file and it will tell you how to
'convert degrees into radians
'Rotation around x-axis
 newx = oldx
 newy = (sin(angle) * oldz) + (cos(angle) * oldy)
 newz = (cos(angle) * oldz) - (sin(angle) * oldy)
'Rotation around y-axis
 newx = (cos(angle) * oldx) - (sin(angle) * oldz)
 newy = oldy
 newz = (sin(angle) * oldx) + (cos(angle) * oldz)
'Rotation around z-axis
 newx = (cos(angle) * oldx) + (sin(angle) * oldy)
 newy = (cos(angle) * oldy) - (sin(angle) * oldx)
 newz = oldz
'PS - If you have any problems with
'this please either
'e-mail me at:
'[email protected] 
'or post a comment below
' -- Thank You --

Download this snippet    Add to My Saved Code

Rotation of points in 3D Comments

No comments have been posted about Rotation of points in 3D. Why not be the first to post a comment about Rotation of points in 3D.

Post your comment

Subject:
Message:
0/1000 characters