<p>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.</p>

<p>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.</p>

CC BY-SA 3.0
2016-06-26T00:09:20.400Z
Could you expand on how this can be used to determine the angle of the tube? Sorry if I'm missing something obvious...
trichoplax is on Codidact now
CC BY-SA 3.0
2016-06-26T00:20:49.083Z
@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.
ratchet freak
CC BY-SA 3.0
2016-06-25T23:33:50.490Z
2016-06-25T23:33:50.490Z
ratchet freak
<p>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:</p>

<ol>
<li>calculating the angle with the square root dot product divided by the length of the vectors.</li>
<li>cartesian to polar function which calculates the y and z rotation values</li>
</ol>

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

<p>Thanks in advance! See below what I have so far.
<a href="https://i.sstatic.net/YOwcg.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/YOwcg.png" alt="enter image description here"></a></p>

CC BY-SA 3.0
2016-06-25T07:01:42.247Z
Ill give you a hint, use cross product.
joojaa
<3d><vectors><mathematics>
How can I draw a tube on basis of position and angle between two 3d points?
MishaHahaha
# How can I draw a tube on basis of position and angle between two 3d points?

(Asked by: username_0 on 2016-06-25)

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](https://i.sstatic.net/YOwcg.png)](https://i.sstatic.net/YOwcg.png)

**Tags:** 3d, vectors, mathematics

> **Comments:**
> **username_1**: Ill give you a hint, use cross product.  

---

## 1 answers

### Answer by username_2 on 2016-06-25. Score: 1 | Accepted answer

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.

> **Comments:**
> **username_3**: Could you expand on how this can be used to determine the angle of the tube? Sorry if I'm missing something obvious...  
> **username_2**: @username_3 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.  

---

