Wiki > TV3D65 Index > TVMathLibrary
MoveAroundPoint
DESCRIPTION
Rotates a point around origin, given radius and horizontal and vertical angles.
DECLARATION
| VB.NET | MoveAroundPoint(vOrigin As TV_3DVECTOR , fRadius As Single , fHorizAngle As Single , fVertAngle As Single) As TV_3DVECTOR |
| C++ | cTV_3DVECTOR MoveAroundPoint(cTV_3DVECTOR* vOrigin , float fRadius , float fHorizAngle , float fVertAngle ) |
PARAMETERS
| NAME | OPTIONAL | DESCRIPTION |
| vOrigin | No | Rotation origin/center |
| fRadius | No | Radius or distance from origin |
| fHorizAngle | No | Horizontal angle |
| fVertAngle | No | Vertical angle |
RETURN VALUE
EXAMPLES
'VB.NET example for a TVcamera looking at a Mesh using move around point
Dim Game_Camera_Distance As Single 'the distance from the look at point
Dim Game_Camera_Rot_X As Single 'the X rotation
Dim Game_Camera_Rot_Y As Single 'the Y rotation
Dim Game_Camera_Origin As TV_3DVECTOR 'the origin Vector
Dim Game_Camera_M_A_P As TV_3DVECTOR 'the Move Around Point vector
'set the distance from the mesh
Game_Camera_Distance = 100
'set the rotational positions, normally you would either have key input or mouse input to rotate around an object.
Game_Camera_Rot_X = 180
Game_Camera_Rot_Y = 50
'set the mesh position as the Origin
Game_Camera_Origin.x = Mesh.GetPosition.x
Game_Camera_Origin.y = Mesh.GetPosition.y
Game_Camera_Origin.z = Mesh.GetPosition.z
Game_Camera.SetLookAt(Mesh.GetPosition.x, Mesh.GetPosition.y, Mesh.GetPosition.z)
'workout the rotation
Game_Camera_M_A_P = Math.MoveAroundPoint(Game_Camera_Origin, Game_Camera_Distance, Game_Camera_Rot_X, Game_Camera_Rot_Y)
Game_Camera.SetPosition(Game_Camera_M_A_P.x, Game_Camera_M_A_P.y, Game_Camera_M_A_P.z)
TIPS
- Use for simple movements around a point/origin.
- For more complex transformations use transformation matrices (Tutorial, Wikipedia).
- To change angle system between degrees and radians use SetAngleSystem of TVEngine.