Elliptical Quater Segment Projection

Started by
1 comment, last by _WeirdCat_ 5 years ago

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!

Advertisement

Noone replied - this means noone knows what quarter elipctical segment means...

Anyway, when you have an eliptical equation you could normalize the direction from elipsoid center, anyway if you wish to iterate through its surface you could extract the vector from angle1 to angle1+some other angle (lets say 0.1)...

This topic is closed to new replies.

Advertisement