Calculating an intersection angle

Hi, i need some mathematics with jME.



I would like to point a 3D arrow object to a certain position. The arrow is always in front of the camera.

Therefore I need to calculate the intersection angle between the direction vector of the arrow and the x-y plane (which has the normalized vector (1,0,0)) to rotate the arrow.



The general problem is done in math by: (I hopw you know what will follow^^):

sin.alpha = (|un|) / (|u||n|).



where u is the directional vector of the arrow and n the normal vector of the plane.





Problem: How can I calculate alpha with the functions provided by jME and FastMath?

With my calculator it would be sin^-1 ((|un|) / (|u||n|)).



By the way how are rotations applied to the spatial… as I attached the arrow to the cameraNode there will be actually TWO rotations for the arrow: first the inherited of the parent cameraNode and the second rotation is calculated by me.



I can think of two possibilities:

  1. the rotations are always applied as if the spatial has not been rotated at the begin of the frame, thus the second rotation overwrites the first rotation within the same frame
  2. the rotations are somehow added thus the second rotation "continues" the first rotation (which would be more complicated for me ;-()



    Are there already examples / alternative ways which can point a spatial to a certain point? Otherwise I would continue with the intersection angle for calculating the proper rotation.










eeep math …  :?

use node.lookAt(Vector3f)



Node.lookAt() takes a world position as argument.

oh,

OK thanks 8)  XD lol  :lol:



But my second question: How are two spatial rotations applied to --> which result can I expect:

  1. the rotations are always applied as if the spatial has not been rotated at the begin of the frame, thus the second rotation overwrites the first rotation within the same frame
  2. the rotations are somehow added thus the second rotation "continues" the first rotation



    Although the question has become unnecessary I'm interested in the answer :wink:

funny that I never asked this question before:



what is the difference between worldTranslation and localTranslation. Maybe this is explained in the wiki?

The lookAt method works excelent.



But the arrow is rotated by its parent movements: the cameraNode.



How can I attach a child to a parent that the child do not inherit the rotation information but only the position information?

mathias4u said:

what is the difference between worldTranslation and localTranslation. Maybe this is explained in the wiki?


local rotation is the rotation of the object itself, in the world rotation, the rotation of the parent nodes is also taken into account.
Make sure to check and understand the TestRoatateAboutPoint example.
A Child always inherits the translation and rotation of its parents.