Skip to content

Commit

Permalink
feat(shared): add ToRadians
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed Mar 20, 2024
1 parent 4c6ce3e commit fbd8c07
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/AltV.Net.CApi/Data/Position.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Drawing;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
Expand Down Expand Up @@ -105,6 +106,11 @@ public float Distance(Position b)
return MathF.Sqrt(diffX * diffX + diffY * diffY + diffZ * diffZ);
}

public Position ToRadians()
{
return new Position((X * MathF.PI) / 180, (Y * MathF.PI) / 180, (Z * MathF.PI) / 180);
}

public static Position operator +(Position a, Position b) => new Position(a.X + b.X, a.Y + b.Y, a.Z + b.Z);

public static Position operator -(Position a, Position b) => new Position(a.X - b.X, a.Y - b.Y, a.Z - b.Z);
Expand Down
5 changes: 5 additions & 0 deletions api/AltV.Net.CApi/Data/Rotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ public bool Equals(Rotation other)
return Roll.Equals(other.Roll) && Pitch.Equals(other.Pitch) && Yaw.Equals(other.Yaw);
}

public Rotation ToRadians()
{
return new Rotation((Roll * MathF.PI) / 180, (Pitch * MathF.PI) / 180, (Yaw * MathF.PI) / 180);
}

public override int GetHashCode() => HashCode.Combine(Roll.GetHashCode(), Pitch.GetHashCode(), Yaw.GetHashCode());
}
}

0 comments on commit fbd8c07

Please sign in to comment.