Reputation: 4219
I will show some images about my problems, so everything will be easier to understand:
My first image shows the axis (x- axis made of cylinders, y-axis made of cones and z-axis made of spheres) and 3 cylinders positioned as follows:
Cylinder above x-axis (right) supports RotZ(PI/4) and RotX(0). Cylinder above the z-axis(left) supports RotX(PI/4) and RotZ(0). Cylinder in the middle supports RotX(PI/4) and RotZ(PI/4).
My second image shows 3 cylinders at exactly the same angle values, but with a sphere at their origin and changed perspective, to make obvious what is weird: that the upper cylinder(experimentally the "x-axis" cylinder) is closer to the middle cylinder (middle cylinder in the first image) than the lower cylinder ("z-axis) cylinder in the first image). The difference can be seen from any perspective, so not the perspective is the problem.
I have considered that the problem might be the way I am making the rotations. Cylinders have 2f length, so I translate the cylinder to (0,1,0) first, so that the point in the middle of the circle at one end of the cylinder. The idea is that I want to rotate around the (0,0,0) point. Then make the rotations.
Could this be the problem?
The code below shows how cylinders are placed
private void addSimpleBound(float x,float y,float z)
{
Cylinder b=new Cylinder();
TransformGroup tg=new TransformGroup();
tg.addChild(b);
TransformGroup element=translate(tg, new Vector3f(0f,1f,0f));
TransformGroup gr=rotate(element,xAngle,zAngle);
elements.addChild(gr);
}
TransformGroup rotate(Node node,
double xAngle,
double zAngle)
{
Transform3D tiltAxisXform = new Transform3D();
Transform3D tempTiltAxisXform = new Transform3D();
tiltAxisXform.rotX(xAngle);
tempTiltAxisXform.rotZ(zAngle);
tiltAxisXform.mul(tempTiltAxisXform);
TransformGroup rotatedGroup = new TransformGroup(tiltAxisXform);
rotatedGroup.addChild(node);
return rotatedGroup;
}// The rotation method
Upvotes: 0
Views: 246
Reputation: 171
Edit:
Per comments, the end points of your cylinders are at
(sqrt(0.5), sqrt(0.5), 0),
(0, sqrt(0.5), sqrt(0.5)),
(sqrt(0.5), 0.5, 0.5)
which means that the distances actually are unsymmetric. For a more symmetric result, the second rotation would have to be around the y axis.
Original answer:
This is not weird at all. The ends of your cylinders are at
(sqrt(0.5), sqrt(0.5), 0),
(0, sqrt(0.5), sqrt(0.5)),
(0.5, sqrt(0.5), 0.5)
The distance from the first end to the second is 1, the distance from the first to the third (or from the second to the third) is sqrt(1 - sqrt(0.5)) < 1.
P.S. if you want to make the image more symmetrical, you could put the end of the third cylinder to (sqrt(0.5),0,sqrt(0.5)).
Upvotes: 1