Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ''' <summary>
- ''' Round a direction vector from an angle in degree
- ''' </summary>
- Public Shared Function Round_Vector(Vector As Vector2, Angle_Degree As Single) As Vector2
- Angle_Degree = DegToRad(Angle_Degree) 'degree to radian
- Dim angle As Single = CSng(Math.Atan2(Vector.Y, Vector.X))
- If (angle Mod Angle_Degree <> 0) Then
- Dim newAngle As Single = CSng(Math.Round(angle / Angle_Degree) * Angle_Degree)
- Return New Vector2(CInt(Math.Cos(newAngle)), CInt(Math.Sin(newAngle)))
- Else
- Return Vector
- End If
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement