Jump to content
  • Advertisement

Elliptical Quater Segment Projection

Recommended Posts


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;
            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?


Share this post

Link to post
Share on other sites

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)...

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!