1
$\begingroup$

Suppose I have a specific angle that I calculate from two vectors, in 3D:

center = {0, 0, 0};
v1 = {1, 0, 0};
v2 = {-1, 0.3, 0.3};
Graphics3D[{Thick, Red, Line[{center, v1}], Blue, Line[{center, v2}]}]

enter image description here

The angle between v1 and v2:

myAngle = VectorAngle[v1, v2]
(*2.74035*)

Question is, how can I feed myAngle into AnglePath3D[]? The result should take the last step on AnglePath3D[] as the reference orientation to generate the next step, according to myAngle. I suspect that this requires the EulerAngles[] calculated at each sequential step, but unsure how to find them to feed into AnglePath3D[] (I'm guessing getting the rotation matrix from each sequential Euler angles(?)).

Thanks!

Edit 1: If, per @chris suggestion, one does path=AnglePath3D[N@ConstantArray[{0, myAngle}, 5], {"Position","RotationTranslation"}]:

Graphics3D[{
  Line[path[[All, 1]]],
  GeometricTransformation[Ellipsoid[{0, 0, 0}, {0.1, 0.05, 0.05}], 
   path[[All, 2]]]
  },
 ImageSize -> 350,
 Axes -> True,
 AxesLabel -> {X, Y, Z}
 ]

enter image description here

This seems to work, but the path has no "depth", as it is contained on a single plane on the Y axis. I'm just guessing there's not enough information in {0, myAngle} to reorient the new step in the same 3D way v2 is reoriented relative to v2 (see below):

enter image description here

If you could explain how to properly specify the last vector as the new 'frame of reference', that would be great. I imagine this requires reorienting this angles on the three axes (X, Y, Z), so that the new step is on the same relative orientation to the last step, as v2 is from v1 in this simple example. Any help/explanation/clarifications would be great.

Thanks!

$\endgroup$
2
  • $\begingroup$ Have you looked at the end of the documentation? It seems to me the last (neat example) gives you the answer? path = AnglePath3D[ N@ConstantArray[{0, -\[Pi]/100}, 200], {"Position", "RotationTranslation"}]; $\endgroup$
    – chris
    Oct 3 at 18:52
  • $\begingroup$ @chris doing AnglePath3D[N@ConstantArray[{0, myAngle},20], {"Position", "RotationTranslation"}]; seems to work. But, why do I need the zero in {0, myAngle}. And, do you know what the relation of this solution to the Euler Angles? Thanks! $\endgroup$ Oct 3 at 19:16
1
+150
$\begingroup$

Actually, I don't understand what you're trying to do. I think saying your purpose clearly can help people understand the problem.

Have you ever tried using

RotationMatrix[{v1, v2}]

to get the rotation matrix. And this can directly used as the input of AnglePath3D.

After some discussion we got

path = AnglePath3D[N@ConstantArray[EulerAngles[RotationMatrix[{v1,v2}]], 5], {"Position", "RotationTranslation"}]
$\endgroup$
7
  • $\begingroup$ Thanks for the comment! I tried to explain better in my edited question. Using RotationMatrix[] requires the coordinates of v1/v2. I'm trying to use the angles calculated with VectorAngle[], as stated in the question. $\endgroup$ Oct 6 at 1:35
  • $\begingroup$ But with only one angle, you can't do a certain rotation. $\endgroup$
    – houzw
    Oct 6 at 1:48
  • $\begingroup$ right! I think I deleted the part about EulerAngles[] (now I re-added that), but you're right. One single angle doesn't tell which general orientation in 3D one should get. So, I think you are close to an answer. I'm guessing finding at each new step the rotation matrix, then calculating the EulerAngles[] iteratively would be a solution? If you post this answer, I think that's it, thanks! $\endgroup$ Oct 6 at 1:57
  • $\begingroup$ So the Euler Angle for each rotation is known? $\endgroup$
    – houzw
    Oct 6 at 2:15
  • $\begingroup$ Well, I think I can calculate it with EulerAngles[]. In fact, I tried path = AnglePath3D[N@ConstantArray[EulerAngles[RotationMatrix[{v1, v2}]], 5], {"Position", "RotationTranslation"}], and this seems to work. But, I'm thinking how can I do this without relying on v1, v2 (because in my more complicated application, the angles I need vary, so I can't just use v1/v2 as a constant). However, I think this gives a good path towards what I'm looking for. Thanks a lot! $\endgroup$ Oct 6 at 2:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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