I am trying to convert this velocity into another 2 dimensional vector at some specified angle:
float maximumVelocity = 1.5f;
float angleInDegrees = 23f;
Vector2 actualVelocityAs2DimensionalVector = {?,?}
At first, I was going to take 1.5, and rotate it after converting the degrees to radians, like so:
double radians = Math.toRadians(angleInDegrees);
Vector2 actualVelocityAs2DimensionalVector = new Vector2(x * Math.cos(radians) - y * Math.sin(radians),
x * Math.sin(radians) + y * Math.cos(radians));
Is this the fastest way to achieve this? This will be happening a lot in my application, and I would think all the cos
and sin
calls are somewhat expensive.