Jump to content

Right Angle to a Direction


Wingnut
 Share

Recommended Posts

Hi gang.  I have another noob question.

   I have a direction vector (-1, 0, 0).  Let's pretend that is "forward".  (it could be a much more complex direction, too)

If I want to "derive"/calc a LEFT and RIGHT direction... based-upon the first direction, what might be the best way?  Or, ANY way.  :)

Essentially, I need v3.leftFromDirection(firstDirection) and v3.rightFromDirection(firstDirection)

Would that be "left orthogonal" and "right orthogonal"?  I think so.

firstDirection.negate() returns the opposite direction, so that condition is handled.

Can anyone help?  Thx!

Link to comment
Share on other sites

You need more information.
You need an eye vector, a target/direction vector and an up vector if Im not mistaken... but I might be crazy/dumb.

I think  a * b = |a| *|b|*cos(90deg) = 0, is a thing too for establishing right angles... but I forget how to resolve that when you only have one vector, It should not be to hard though...


>_< this makes me want to go back to school... there was a time where I knew all this off the top of my head.

Link to comment
Share on other sites

It works fine, no matter.  I used Cross(BABYLON.Vector3.Up(), firstDirection.negate())  (for a left-aiming direction)

https://www.babylonjs-playground.com/#1ND6TH#35

Line 371 uses P8's value for the top right arrow direction.

In line 401, I call "echoPulsar" with the "left" parameter.  We want to "echo" the upper right arrow... but aiming leftward instead.

Another arrow has been placed on the backside of the red mesh... aiming leftward... when viewed from initial upper-right arrow.

Adam's call is in line 289.  :)  Seems to work.  Ignore the difference in contactPoint/position.  That is expected.

 

 

Link to comment
Share on other sites

In my mind that makes no sense.  That's working under the assumption that the up direction to the first direction is always 0,1,0. But what if that not really the "up" direction.

@adam That fills in some blanks for me, cool thanks I figured its all relates to your point of reference.

Link to comment
Share on other sites

I was picturing a spaceship or an airplane, and how as its pitchs and rolls the up vector changes and effects the direction of yaw, so up cant always be 0,1,0 unless you are using a fixed reference point.  Which then the vector's right angle is always in global not local.

Link to comment
Share on other sites

Pitch and roll does not affect yaw.  :o  If it does, you have a broken airplane. 

Are you thinking about directions... spinning on their z-axis?  Rolled directions?   Yeah, I was there... until I realized that spinning arrows still fly the same direction.

Link to comment
Share on other sites

So again it comes down to three points your "eye" position, your forward vector and your up vector:

When doing Cross(BABYLON.Vector3.Up(), firstDirection.negate())
your making the assumptions that the eye vector is 0,0,0 and the up is 0,1,0

which limits the number of "right" angles.

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.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...