Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'WRITTEN BY HAZARDX/CODEAPARAT/TIM
- 'TRANSLATED FROM C++ TO VB.NET BY THEVIDEOVOLCANO
- Public Class THelper
- Public Shared Function RadianToDegree(ByVal radians As Double) As Double
- Return radians * Convert.ToDouble(180.0 / Math.PI)
- End Function
- Public Shared Function DegreeToRadian(ByVal degrees As Double) As Double
- Return degrees * Convert.ToDouble(Math.PI / 180.0)
- End Function
- Public Shared Function DirectionToHeading(ByVal dir As GTA.Math.Vector3) As Double
- dir.Z = 0.0F
- dir.Normalize()
- Return RadianToDegree(-Math.Atan2(dir.X, dir.Y))
- End Function
- Public Shared Function HeadingToDirection(ByVal Heading As Double) As GTA.Math.Vector3
- Heading = DegreeToRadian(Heading)
- Dim res As GTA.Math.Vector3
- res.X = Convert.ToDouble(-Math.Sin(Heading))
- res.Y = Convert.ToDouble(Math.Cos(Heading))
- res.Z = 0.0F
- Return res
- End Function
- Public Shared Function DirectionToRotation(ByVal dir As GTA.Math.Vector3, ByVal roll As Double)
- dir = GTA.Math.Vector3.Normalize(dir)
- Dim rotval As GTA.Math.Vector3
- ' Z rotation calculated from the Floor - Vector of Direction . (Normal X and Z)
- rotval.Z = -RadianToDegree(Math.Atan2(dir.X, dir.Y))
- ' X rotation calculated from the angle between the length of the floor and the height Vectors
- Dim rotpos As GTA.Math.Vector3 = GTA.Math.Vector3.Normalize(New GTA.Math.Vector3(dir.Z, New GTA.Math.Vector3(dir.X, dir.Y, 0.0F).Length(), 0.0F))
- rotval.X = RadianToDegree(Math.Atan2(rotpos.X, rotpos.Y))
- rotval.Y = roll 'Roll
- Return rotval
- End Function
- Public Shared Function RotationToDirection(ByVal Rotation As GTA.Math.Vector3) As GTA.Math.Vector3
- Dim rotZ As Double = DegreeToRadian(Rotation.Z)
- Dim rotX As Double = DegreeToRadian(Rotation.X)
- Dim multiXY As Double = Math.Abs(Convert.ToDouble(Math.Cos(rotX)))
- Dim res As GTA.Math.Vector3
- res.X = Convert.ToDouble(-Math.Sin(rotZ)) * multiXY
- res.Y = Convert.ToDouble(Math.Cos(rotZ)) * multiXY
- res.Z = Convert.ToDouble(Math.Sin(rotX))
- Return res
- End Function
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement