A bit lost with axis and rotations
A bit lost with axis and rotations
Hi guys.
I'm starting having results with jreality, but it's a long way.
For now, I can translate my objects (boxes in my storage facility), it's a big win.
Here's the thing :
being new to 3D, I'm wondering which is the "proper" way to use axis.
Say I have a surface representing the ground of my warehouse.
Should it be on X and Y, or X and Z ? Therefore should Z or Y or X??? be the altitude ?
Is there any page explaining all this, and how rotations work ?
Example :
I receive a message to create a forklift at (1,1,0)
Then another to move it to (3,5,0),
and this implies to rotate the forklift so it's along the (2,4,0) vector.
Any "proper" way to do so ?
That would be very helpful.
Thanks for the help guys!!
I'm starting having results with jreality, but it's a long way.
For now, I can translate my objects (boxes in my storage facility), it's a big win.
Here's the thing :
being new to 3D, I'm wondering which is the "proper" way to use axis.
Say I have a surface representing the ground of my warehouse.
Should it be on X and Y, or X and Z ? Therefore should Z or Y or X??? be the altitude ?
Is there any page explaining all this, and how rotations work ?
Example :
I receive a message to create a forklift at (1,1,0)
Then another to move it to (3,5,0),
and this implies to rotate the forklift so it's along the (2,4,0) vector.
Any "proper" way to do so ?
That would be very helpful.
Thanks for the help guys!!
-
- Posts: 48
- Joined: Mon 16. May 2011, 16:29
Re: A bit lost with axis and rotations
I think the coordinate system is usually aligned so that y points upwards and x, z are horizontal.
You could use the class MatrixBuilder i guess. A Translation would be
MatrixBuilder.euclidean().translate(new double[]{2, 4, 0, 1}).rotateFromTo(new double[]{1, 0, 0, 1}, new double[]{2, 4, 0, 1}).assignTo(sgc);
For details you can consult the tutorials at
http://www3.math.tu-berlin.de/jreality/ ... formations
and
http://www3.math.tu-berlin.de/jreality/ ... ilder.html
You could use the class MatrixBuilder i guess. A Translation would be
MatrixBuilder.euclidean().translate(new double[]{2, 4, 0, 1}).rotateFromTo(new double[]{1, 0, 0, 1}, new double[]{2, 4, 0, 1}).assignTo(sgc);
For details you can consult the tutorials at
http://www3.math.tu-berlin.de/jreality/ ... formations
and
http://www3.math.tu-berlin.de/jreality/ ... ilder.html
Re: A bit lost with axis and rotations
Hi.
Thanks for your answer.
Considering I basically work in 2D for rotations (always on the same plan), I ended up using a simple way:
I have the coordinates of my new position, and the vector between new and old position at each update of my position,
say coordinates(x, y, z) and vector(x, y, z=0)
Is that a proper way to do things ?
Thanks for your answer.
Considering I basically work in 2D for rotations (always on the same plan), I ended up using a simple way:
I have the coordinates of my new position, and the vector between new and old position at each update of my position,
say coordinates(x, y, z) and vector(x, y, z=0)
Code: Select all
//angle of the vector
double angleZ = Math.atan2(vector.getY(), vector.getX());
//just to have an axis on z
double axis1[] = { coordinates.getX(), coordinates.getY(), 0 };
double axis2[] = { coordinates.getX(), coordinates.getY(), 1 };
MatrixBuilder.euclidean().rotate(axis1, axis2, angleZ).translate(coordinates.getX(), coordinates.getY(), coordinates.getZ()).assignTo(component);
-
- Posts: 48
- Joined: Mon 16. May 2011, 16:29
Re: A bit lost with axis and rotations
looks quit good I think.
i think the transformations that are at the end of the statement are executed first. ie. in your case first the translation and afterwards a rotation around the origin.
check this page for the use of .rotate(...)http://www3.math.tu-berlin.de/jreality/ ... ilder.html
If you want the forklift to move smoothly here's the tutorial:
http://www3.math.tu-berlin.de/jreality/ ... ation_tool
i think the transformations that are at the end of the statement are executed first. ie. in your case first the translation and afterwards a rotation around the origin.
check this page for the use of .rotate(...)http://www3.math.tu-berlin.de/jreality/ ... ilder.html
If you want the forklift to move smoothly here's the tutorial:
http://www3.math.tu-berlin.de/jreality/ ... ation_tool
Re: A bit lost with axis and rotations
yeah, it looks good, you just have to choose what you want to do first:
rotation -> translation
translation -> rotation
don't mix this up, this has to be consistent through your whole code.
rotation -> translation
translation -> rotation
don't mix this up, this has to be consistent through your whole code.
Re: A bit lost with axis and rotations
Thanks for your answers.
I just made some tests, it works fine with rotate().translate(), my box is moved, then rotates on itself, things are good.
I'm taking the next step now, moving the cameras.
The situation is a bit different, translations are on all 3 axes (and without the auto-orientation thing i did for boxes, so far so good), and rotations on itself are on 2 axes (up/down, left/right, but no tilt).
I'm gonna give a try at rotateFromTo and other sweets.
Hopefully my next post will be "I did it!"
Then another post about "how to have an ambient light ?"
About the animation tool, as in my component I only have notifications about the new position of my boxes which I can't predict, I'm not sure it fits the need.
I'm really starting to enjoy this project!
Thanks guys!
I just made some tests, it works fine with rotate().translate(), my box is moved, then rotates on itself, things are good.
I'm taking the next step now, moving the cameras.
The situation is a bit different, translations are on all 3 axes (and without the auto-orientation thing i did for boxes, so far so good), and rotations on itself are on 2 axes (up/down, left/right, but no tilt).
I'm gonna give a try at rotateFromTo and other sweets.
Hopefully my next post will be "I did it!"
Then another post about "how to have an ambient light ?"
About the animation tool, as in my component I only have notifications about the new position of my boxes which I can't predict, I'm not sure it fits the need.
I'm really starting to enjoy this project!
Thanks guys!
Re: A bit lost with axis and rotations
It went fine so far.
Now I'm wondering if I could change the coordinate system to meter unit (not quite sure I'm clear...), considering my .obj models and the incoming positions data is in meters,
and I'd like to use raw data.
Any possibility ?
edit :
I tried to rotate my camera on itself, but it seems it revolves around the origin, I think I've missed something...
I need to be able to do something like look up, down, left, right.
I receive angles on vertical and horizontal axis, I have to change my point of view angle, like a person would do.
Thanks.
Now I'm wondering if I could change the coordinate system to meter unit (not quite sure I'm clear...), considering my .obj models and the incoming positions data is in meters,
and I'd like to use raw data.
Any possibility ?
edit :
I tried to rotate my camera on itself, but it seems it revolves around the origin, I think I've missed something...
I need to be able to do something like look up, down, left, right.
I receive angles on vertical and horizontal axis, I have to change my point of view angle, like a person would do.
Thanks.
Re: A bit lost with axis and rotations
As far as i understood, depends your problem on the size, scaled by jreality. You have to overwrite the global scalingfactor with 1, then you should have something like meters for your application. And don't use,
because this enables also a kind of scaling. (for the TerrainAligned I'm not sure, but the second for sure ;) )
Code: Select all
JRViewer v = new JRViewer();
...
v.addContentSupport(ContentType.TerrainAligned);
or
v.addContentSupport(ContentType.CenteredAndScaled);
Re: A bit lost with axis and rotations
Or better, watch into these classes and look how they are working or use simple
"Raw" should just use the original sizes of your .obj-files
Code: Select all
JRViewer v = new JRViewer();
v.addContentSupport(ContentType.Raw);
Re: A bit lost with axis and rotations
Hi, thanks Andre for the answer.
As I'm using the jogl viewer, it seems I don't have these methods available...
Maybe I'm gonna have to multiply my positions by a common factor.
Example :
my test.obj file contains data in centimers for a ~600x250x250 box.
Data I'm receiving about the positioning is in meters, like (x, y, z) = (452.6, 229.3, 5.4)
and considering y and z should be inverted as z is the height in the system feeding data to me (which might be a problem with rotations anyway).
Maybe I should just multiply positions by 1000 and things will work fine ?
About the camera problem I'm facing, I'm lost, it's like axis are swapped and rotations are around the origins and not the camera itself.
But this might be totally normal and I'm just stupid ( very likely :) )
Thanks for the support, jreality is fun!
As I'm using the jogl viewer, it seems I don't have these methods available...
Maybe I'm gonna have to multiply my positions by a common factor.
Example :
my test.obj file contains data in centimers for a ~600x250x250 box.
Data I'm receiving about the positioning is in meters, like (x, y, z) = (452.6, 229.3, 5.4)
and considering y and z should be inverted as z is the height in the system feeding data to me (which might be a problem with rotations anyway).
Maybe I should just multiply positions by 1000 and things will work fine ?
About the camera problem I'm facing, I'm lost, it's like axis are swapped and rotations are around the origins and not the camera itself.
But this might be totally normal and I'm just stupid ( very likely :) )
Thanks for the support, jreality is fun!
Re: A bit lost with axis and rotations
The jogl-viewer just describes the rendering backend you are using, what I mean is the kind of viewer you are using, because there are several versions of running viewers in jReality, eg. to point out an older viewer "ViewerApp" or a new viewer with VR-Support "JRViewerVR":
at the wiki you find some tutorials about viewers:
http://www3.math.tu-berlin.de/jreality/ ... r_Tutorial
especially this one should be interesting for you:
http://www3.math.tu-berlin.de/jreality/ ... ctionality
Have fun and keep on working. I try to answer to all Questions I'm able.
best
Andre
at the wiki you find some tutorials about viewers:
http://www3.math.tu-berlin.de/jreality/ ... r_Tutorial
especially this one should be interesting for you:
http://www3.math.tu-berlin.de/jreality/ ... ctionality
Have fun and keep on working. I try to answer to all Questions I'm able.
best
Andre