Sign in to follow this  
bfogerty

2D perpendicular vector

Recommended Posts

Hello. I am writing a generic Matrix / Vector library for the C# language. I am not especially great at math and that is partly why I am doing this as an exercise. One of the methods I would like is to calculate the 2D perpendicular vector to another. I wrote the following code which seems to do that just fine.
        public Vector3D getPrependicular()
        {
            float mx = this.Y / this.X;
            mx = -1 / mx;

            float y = (this.X * mx);

            return new Vector3D(this.X, y, 1);
        }
However when I draw the perpendicular vector, although the angle is 90 degrees, its distance is scaled drastically. I would like the length of the perendicular vector to be that of the original vector. How would I go about doing that? Thanks in advance!

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

Sign in to follow this