Hello,
I found this pieace of code whilst looking through unity:
// Project a direction onto elliptical quarter segments based on forward, sideways, and backwards speed.
// The function returns the length of the resulting vector.
public float MaxSpeedInDirection (Vector3 desiredMovementDirection)
{
if (desiredMovementDirection == Vector3.zero)
{
return 0;
}
else
{
float zAxisEllipseMultiplier = (desiredMovementDirection.z > 0 ? movement.maxForwardSpeed : movement.maxBackwardsSpeed) / movement.maxSidewaysSpeed;
Vector3 temp = new Vector3 (desiredMovementDirection.x, 0, desiredMovementDirection.z / zAxisEllipseMultiplier).normalized;
float length = new Vector3 (temp.x, 0, temp.z * zAxisEllipseMultiplier).magnitude * movement.maxSidewaysSpeed;
return length;
}
}
It returns the max speed in a given direction, i understand what it does visually for instance setting forward,backward, sideways speed to be the same would be equivlent to a circle ? so the speed in direction is the same radius length regardless.
However, i havent been able to find much information about "Elliptical Quater Segments" particuarly projecting a vector onto one, does anyone have any math resources that can aide with the understanding of ellipticals? especlialy in regards to this specific instance?
Thanks!