Jump to content

How to rotate a vector to make it tangent


redpeak

Recommended Posts

You can do this with two cross products.

First you take the normal, and cross it with v to get a vector orthogonal to both N and v. Then you cross that vector with N again, to get your original vector, but now orthogonal to both N and the other vector you already generated; this means it'll be tangent to your sphere.

vector tmp = cross(v@v, v@N);
v@v = cross(tmp, v@N);

Also, make sure your v@v attribute you're creating has three components, not two.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...