Get location of end of Line in rootNode spatial, from pivot node local

Hi I am trying to place a geometry in my scene based on the location of the end of a line in a pivot node, but without much luck.
I created a pivot node which is given its location and rotation from VR controller. In the pivot node is a geometry showit where I draw a line,the length of the lidar reading, down the z axis of showit . I want to place a geometry at the end of the line in the rootNode space, but I can’t figure out how to get that end point ( location vector ) in world space or rootNode space. I can see the point or where the placement should be, but how do I get the vector in the rootNode space so I can place a geometry at that location.

Node pivot;

Line l3 = new Line(Vector3f.ZERO, new Vector3f(0f, 0f, .01f));
private Geometry line;
   Geometry showit;
  showit = new Geometry("Ball", smallSphere);
    showit.setLocalRotation(new Quaternion(0.47458643f, -0.001760408f, 9.491699E-4f, 0.8802066f));

Geometry zline = new Geometry("Line", l3);

pivot = new Node(“pivot node”);
pivot.setLocalRotation(new Quaternion(0.47458643f, -0.001760408f, 9.491699E-4f, 0.8802066f));
line = new Geometry(“Line”, smallSphere);

// Update pivot
Quaternion q = VRApplication.getVRinput().getFinalObserverRotation(index);
Vector3f v = VRApplication.getVRinput().getFinalObserverPosition(index);

    if (q != null && v != null) {
        Q1 = q.clone();
        v1 = v.clone();
        pivot.setCullHint(CullHint.Dynamic); // make sure we see it

// In a thread updating lidar reading
lidar = distance / 100.0f;// convert centimeters to meters
x = Float.parseFloat(data[1]);
y = Float.parseFloat(data[2]);
z = Float.parseFloat(data[3]);
w = Float.parseFloat(data[4]);
accuracy = Float.parseFloat(data[5]);
Q1.set(x, y, z, w);

                    if (showit != null) {
                        v1 = zline.getLocalTranslation().add(new Vector3f(0f, 0f, lidar));
                        //v1 = Q1.mult(v1);
                        direction = new Line(showit.getLocalTranslation(), v1);


// In the simpleUpdate method
zline.setLocalTranslation(showit.getLocalTranslation());emphasized text

    if (direction != null) {
        line = new Geometry("liDarMeasure", direction);



So you want to convert a point from local space to world space.

Okay I have add the code, but I don’t get desired result. I’m trying to put and object at the end point of the line ( see drawing below) .
It’s not clear how to get that point .

line = new Geometry(“liDarMeasure”, direction);
Vector3f v3 ;
v3 =pivot.localToWorld(showit.getLocalTranslation(),null);
addBox(v3.add(direction.getEnd()), showit.getLocalRotation(), 0.50f);

You want the end point of the line (which is local to ‘line’) in world space. I don’t know how you made your line mesh so I can only guess that you really want something like:

Vector3f endOfTheLineInLocalSpace = .....
Vector3f endOfTheLineInWorlsSpace = line.localToWorld(endOfTheLineInLocalSpace, null);

I’m not getting something, I will simplify the problem so I can better understand why the result are so different than what I expect.
I am using HTC Vive, the controller updates it’s location with:
Quaternion q = VRApplication.getVRinput().getFinalObserverRotation(index);
Vector3f v = VRApplication.getVRinput().getFinalObserverPosition(index);
(v,q) is where the controller(location vector v)and what rotation(Quaterion q) it has(orientation) a direction it is pointing.
from the origin ( v,q) I want to place an object some distance d from the in the direction the controller is pointing.

Vector3f endOfTheLineInWorlsSpace = Vector3f.ZERO.add(new Vector3f(0f, -lidar, 0f)); draw along the y axis
Vector3f startOfTheLineInWorlsSpace = Vector3f.ZERO;
Line l1 = new Line(startOfTheLineInWorlsSpace, endOfTheLineInWorlsSpace);
Geometry LineAdd = new Geometry(“addLine”, l1);
Sphere sphere = new Sphere(16, 16, .005F);
Geometry dot = new Geometry(“dot”, sphere);
dot.setLocalTranslation(v.add(new Vector3f(0f, -lidar, 0f)));
The LineAdd geometry shows up where it is expected, but the dot geometry does not . How do I use the direction the controller is pointed, and the distance I provide to place a geometry the distance away in the direction?

I apologize if I am misunderstanding any part of your scenario since it is in VR and may have limitations I’m overlooking or don’t understand.

But I think I would approach this problem in a much simpler way with less math.

If your line already has the start/end points here:

Then the dot should show up in the right place if you attach it to the rootNode and call:

And then if you need to find the end of the line after it the line has been rotated, the easiest way would be to attach a new empty Node to the end of your line when you create it, so that node always be at the end of the line no matter how you move/rotate/scale the line thanks to its parent/child relationship. Then, to retrieve the new location after rotation, you can just call nodeAttachedToEndOfLine.getWorldTranslation() and then attach the dot there.

Are you asking me how to multiple a direction vector by a distance and add it to a location?



I have spent some time with the problem and observe the following.
when I run the code bellow, I set a geometry b01 ( a box ) local rotation, then I get b01 local translation save to locvec1, I use the locvec1 to create a line from 0,0,0 to locvec1 plus the distance. Now this is where I am confused. When I create a Box with Box b1 = new Box(end, .01f, .01f, .01f); , where end is the end of the line I created, the box shows up at the end of the line like I expect, but when I use the same end to place mark.setLocalTranslation(newPl3.getEnd()); it does not place the object ate the end?

What is going on with Box b1 = new Box(end, .01f, .01f, .01f); where it ends up in the right place but
Vector3f locvec1 = b01.getLocalTranslation();
Line newPl3 = new Line(Vector3f.ZERO, locvec1.add(0, lidar, 0));
Geometry newline = new Geometry(“addLine”, newPl3);
Vector3f end = newPl3.getEnd();

        Box b1 = new Box(end, .01f, .01f, .01f);
        Geometry box = new Geometry("BOX", b1);

        Geometry mark = new Geometry("Mark", smallSphere);


Because b1’s position is within the space of “box” and so is rotated by Q1.

mark’s position is relative to its parent and in its parent’s space… so only rotated by whatever rotation pivot has.

I think maybe you need to meditate on the scene graph documentation a while.