2
$\begingroup$

I'm struggling with this idea of creating two particles in 3d and draw a tube between them. I can't figure out how to properly set the angle of the tube. I've used two approaches:

  1. calculating the angle with the square root dot product divided by the length of the vectors.
  2. cartesian to polar function which calculates the y and z rotation values

I'm obviously missing something (and I'm not that good in math). So what's my approach?

Thanks in advance! See below what I have so far. enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ Ill give you a hint, use cross product. $\endgroup$
    – joojaa
    Jun 25, 2016 at 7:01

1 Answer 1

1
$\begingroup$

The simplest solution is to use a lookat matrix. This is a matrix calculated from a "eye" point, a "target" point and an up vector.

The resulting matrix will then make the Z axis point from the eye to the target and the y axis in the general direction of up.

$\endgroup$
2
  • $\begingroup$ Could you expand on how this can be used to determine the angle of the tube? Sorry if I'm missing something obvious... $\endgroup$ Jun 26, 2016 at 0:09
  • 2
    $\begingroup$ @trichoplax you don't even need the angle. You rarely, if ever, do for setting up geometry. You can nearly always skip getting the angle explicitly because 99% of the time you will be feeding it into a sin or cos right after you get it from a asin or acos. $\endgroup$ Jun 26, 2016 at 0:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.