You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've got a need for finding an orthogonal (perpendicular) vector of a certain magnitude in one of my projects.
I have a function that does the job, but I'd prefer to make it a part of Victor.js. Here's the function:
/** * Returns a new vector thats orthogonal/perpendicular to the given * vector. * Mathematical rules: * - the dot product of two orthogonal vectors is zero. * - the magnitude of a 2d vector is the square root of the sum of * its components. * - ^ two equations. components = the two unknowns. */getOrthogonal(vector,magnitude){magnitude=magnitude||1if(vector.x===0){returnnewVictor(magnitude,0)}if(vector.y===0){returnnewVictor(0,magnitude)}constj=Math.sqrt((Math.pow(magnitude,2)/(1+(Math.pow(vector.y,2)/Math.pow(vector.x,2)))))consti=-(vector.y/vector.x)*jreturnnewVictor(i,j)}
I was wondering if you would accept a merge request for a method that would work as follows:
varvec1=newVictor(100,200);varvec2=vec1.makeOrthogonal(10);// vec 2 is a vector with a magnitude of 10 that's orthogonal to vec1
The text was updated successfully, but these errors were encountered:
I've got a need for finding an orthogonal (perpendicular) vector of a certain magnitude in one of my projects.
I have a function that does the job, but I'd prefer to make it a part of Victor.js. Here's the function:
I was wondering if you would accept a merge request for a method that would work as follows:
The text was updated successfully, but these errors were encountered: