Matrix stuff
-
On 21/01/2013 at 17:30, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 12
Platform: Mac OSX ;
Language(s) : C++ ;---------
HiI am trying to learn about how Matrices behave and interact with each other. For a small project I need a simple alignment tool where I can, for example, align one box at the end of another, or center just the X axis, etc.
My specific question is with something like the following code.
before:
op1 AbsPos = 100,100,100
op2 AbsPos = 200,200,200op2->Remove(); doc->InsertObject(op2, op1, NULL);
After:
op1 AbsPos = 100,100,100
op2 AbsPos = 300,300,300When I make op2 a child of op1 "by hand" by dragging it in C4D:
op2 AbsPos = 100,100,100What is the transformation to do after InsertObject, taking into account rotation?
Thanks
Peter
-
On 21/01/2013 at 19:12, xxxxxxxx wrote:
your code does not contain any matrices, these are all vectors. there is also no method
being provided by the SDK called AbsPos. there is BaseObject.SetAbsPos() which sets
the BaseObjects position in relation to a parent object (local coordinates). for an
object with no parent object local and global coordinates are the same.if you want to acces an objects global position coordinates you can either use BaseObject.
GetMg()/ .SetMgg()(the offset vector of the written/red matrix is the global position of that
object) or you can directly access the coordinate ids of an object.your basic misconception is that you seem to think that absolute and relative coordinates are
the same as global and local coordinates, which is not the case. abs/rel coords are tied to the
freeze coordinates system in c4d. you might want to read the description on matrices an the
c4d coordinate system in the python sdk ( can be 1:1 applied on cpp). without freezing the
coords of an object abs and rel coords are always the same (the local coords).http://www.thirdpartyplugins.com/python_r14/modules/c4d/Matrix/index.html#c4d.Matrix
-
On 22/01/2013 at 01:33, xxxxxxxx wrote:
Originally posted by xxxxxxxx
your basic misconception is that you seem to think that absolute and relative coordinates are
the same as global and local coordinates, which is not the case. abs/rel coords are tied to the
freeze coordinates system in c4d. you might want to read the description on matrices an the
c4d coordinate system in the python sdk ( can be 1:1 applied on cpp). without freezing the
coords of an object abs and rel coords are always the same (the local coords).http://www.thirdpartyplugins.com/python_r14/modules/c4d/Matrix/index.html#c4d.Matrix
This information is also included in the C++ SDK docs in the guide _C++ Transition to CINEMA 4D R12 _(Getting your Code to Work -> Freeze Transformations).
-
On 23/01/2013 at 07:15, xxxxxxxx wrote:
The C.O.F.F.E.E. SDK also contains a pretty helpful article called "Using matrices" that explains a lot about that matter. And the Python SDK has some more information in the article "c4d.Matrix".
Another very good resource is the tutorial you can find in the CINEMA 4D help. Open the help, then go to "Manual > Tutorials > XPresso Tutorials > Math in XPresso". Vectors, how they represent positions, directions and rotations; matrices, it's all explained in detail.
-
On 23/01/2013 at 14:01, xxxxxxxx wrote:
Thanks for the replies.
I realize my 'code' didn't contain any matrices. It was simply meant to illustrate.
I don't know how many times I have read both the Expresso and C++ version of that article.My simple question was:
when I make an object a child of another object in C4D (not in a plugin) my child object remains in the same position relative to the document (and that's its global position?)when I try to do the same thing in C++ I use Remove() and InsertObject() and my object becomes the child but it's global position changes because the child's coordinates are now relative to the parent.
Is there a function that takes the parent's position into account?
Thanks
-
On 23/01/2013 at 14:18, xxxxxxxx wrote:
it is because you are setting the coordinates in local space.
for an object with no parent object local and global coordinates are the same.
read my first posting or the mentioned articles. absolute coords are not world coords.
-
On 23/01/2013 at 15:19, xxxxxxxx wrote:
Thanks
I solved it. Yikes. It's all about global vs. local. Tried to make it more complicated than it is.
Peter