Java3D Vector3d.angle(Vector3d)

• 01-20-2009, 03:12 PM
Duesentrieb
Java3D Vector3d.angle(Vector3d)
Hello Folks

I am new here and i hope you can help me. Here my question:

Code:

```                _v3dA = new Vector3d(1, [B]0[/B], 0);                 _v3dB = new Vector3d(1, [B]1[/B], 0);                 double angleZ = _v3dA.angle(_v3dB);```
and

Code:

```                _v3dA = new Vector3d(1, [B]1[/B], 0);                 _v3dB = new Vector3d(1, [B]0[/B], 0);                 double angleZ = _v3dA.angle(_v3dB);```
is always 45 Degrees without a prefix. How can I know in which direction the angle is? Or do i misunderstand something?

Thanks for hints,
Duesentrieb
• 01-20-2009, 03:43 PM
Fubarable
what do you mean "without a prefix"? angles don't have direction, they just have value. In other words, an angle is a scalar value.
• 01-20-2009, 07:27 PM
Duesentrieb
So how can I know the angle is for example 90 degrees and nor 270 degrees?
• 01-20-2009, 08:27 PM
Fubarable
You don't. If you go to the API for Vector3D#angle(...), it tells you that the return value is constrained to be between 0 and PI (180 degrees). Thus it will never return 270 degrees.

And this makes sense because in 3 dimensions there really is little difference between 90 and 270 degrees.
• 01-20-2009, 08:45 PM
Duesentrieb
Yes thank you. The result is between 0 and pi.

So how can I do this for example:

I have 2 different (a+b) line in a 3d room. now i wanna translate line a parallel to line b. How can I do this?
• 01-20-2009, 08:47 PM
Fubarable
I'm not sure how to do this in Java3D as I'm not really versed in this library. Best of luck.