I need to rotate an object, and all its children, around X axis (pitch action).
To do that I use myobject.Pitch(degreeAngle).
The object rotate correctly of degree angle.
At this point I need to move the rotation Y axis offset to an arbitrary position and not to 0 default value.
For eg:
My object draw a square with lines (0/0/0, 10/0/0, 10/10/0, 10/0/0, 0/0/0).
I would like pitch X using a Y different than 0, for example Y=50, so actually my only solution is to drive square how (0/-50/0, 10/-50/0, 10/-40/0, 0/-40/0, 0/-50/0) and then set object.position.y to 50 so it draw to scene at (0/0/0, 10/0/0, 10/10/0, 10/0/0, 0/0/0) and when I object.Pitch(30) I can se the object rotate in a large circle.
There is a way to move the Y ration fulcrum without move entrire object coordinates ?
Thank you very much
Last edit: shine world 2018-02-06
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There is a way to move the Y ration fulcrum without move entrire object coordinate
An object is define by many vertices (in you case 4) if you rotate object, all vertices are rotated. it's a normal behaviour. Remember apply rotation to parent rotate child around. Child object are not independant. so you must travel your parent object and apply rotation to child one by one
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Before to insert images or video I will try to explain in another way.
Any object, in my case a TGLLines, can be placed in the scene using its Position property.
Any object can pitch, roll, and turn, but uses always x0:y0:z0 how fulcrum of rotation.
I would like to pitch,roll and turn changing this point, for example in the x10:y12:z3 in a object with with100height100deep100.
I'm using this to rotate a toolpath, stored in TGLLines, in a CNC program.
In CNC system the rotation axis (A) is used to rotate the toolpath and can be placed anywhere in the axes table (not fixed to x0y0z0 of toolpath object).
Thank you very much in advance.
Last edit: shine world 2018-02-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok if i understand well rotation is with arbitary axis. This axis is alway place at 0,0,0 in world space ? or in the ModelSpace ?I see 2 solutions
1st : Have auxiliarry axis based on the object position.
In GLVectorGeometry unit you can find :
{CalculatesavectorperpendiculartoN.Nisassumedtobeofunitlength,subtractoutanycomponentparalleltoN}functionVectorPerpendicular(constV,N: TAffineVector):TAffineVector;// Reflects vector V against N (assumes N is normalized)functionVectorReflect(constV,N: TAffineVector):TAffineVector;// Rotates Vector about Axis with Angle radiansprocedureRotateVector(varvector : TVector;constaxis : TAffineVector;angle : Single);overload;// Rotates Vector about Axis with Angle radiansprocedureRotateVector(varvector : TVector;constaxis : TVector;angle : Single);overload;// Rotate given vector around the Y axis (alpha is in rad)procedureRotateVectorAroundY(varv : TAffineVector;alpha : Single);// Returns given vector rotated around the X axis (alpha is in rad)functionVectorRotateAroundX(constv : TAffineVector;alpha : Single):TAffineVector;overload;// Returns given vector rotated around the Y axis (alpha is in rad)functionVectorRotateAroundY(constv : TAffineVector;alpha : Single):TAffineVector;overload;// Returns given vector rotated around the Y axis in vr (alpha is in rad)procedureVectorRotateAroundY(constv : TAffineVector;alpha : Single;varvr : TAffineVector);overload;// Returns given vector rotated around the Z axis (alpha is in rad)functionVectorRotateAroundZ(constv : TAffineVector;alpha : Single):TAffineVector;overload;
in each GLScene'sObject you can find some usefull function and propertie like :
{ Calculates the object's barycenter in absolute coordinates.
Default behaviour is to consider Barycenter=AbsolutePosition
(whatever the number of children).
SubClasses where AbsolutePosition is not the barycenter should
override this method as it is used for distance calculation, during
rendering for instance, and may lead to visual inconsistencies. }
function BarycenterAbsolutePosition: TVector; virtual;
{ Calculates the object's barycenter distance to a point. }
function BarycenterSqrDistanceTo(const pt: TVector): Single;
{ Shall returns the object's axis aligned extensions.
The dimensions are measured from object center and are expressed
<i>with</i> scale accounted for, in the object's coordinates
(not in absolute coordinates).
Default value is half the object's Scale. }
function AxisAlignedDimensions: TVector; virtual;
function AxisAlignedDimensionsUnscaled: TVector; virtual;
ect....
and
procedure MoveObjectAround(anObject: TGLBaseSceneObject; pitchDelta, turnDelta: Single);
So i think by using MoveObjectAround it will be possible. For example, if i understand you have a toolpath like a simple circle. This Toolpath is alway place at 0,0,0. your object is at 10,15,20.
Solution :
1. Make a copy of the toolpath
2. Move, and rotate the temp toolpath relative to the axis of the object and rotation axis choosen
3. Translate the object along the chosen axis of Circle Toolpath Radius
4. Do a MoveObjectAround
2nd : You need translate your object at 0,0,0 (like in this video i found on subject : https://www.youtube.com/watch?v=yELs34X2UXc )
Make the transformation and replace the objet to initial pos
I hope it will help a little
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've traslated all TGLLines vectors with the desired offset in X/Y/Z (model world), so the TGLLines object (scene world) can be moved in scene using same complementary offset in Position.x/y/z property and then I can rotate/turn/pitch :)
Thank you,
without the help of this site I think I would not have arrived where I am now.
GLSCENE make simple to use OpenGL to everyone and reduce a lot the amount of required code.
I'm using a free software called Open Broadcaster Software, very powerfull !!!
I need to rotate an object, and all its children, around X axis (pitch action).
To do that I use myobject.Pitch(degreeAngle).
The object rotate correctly of degree angle.
At this point I need to move the rotation Y axis offset to an arbitrary position and not to 0 default value.
For eg:
My object draw a square with lines (0/0/0, 10/0/0, 10/10/0, 10/0/0, 0/0/0).
I would like pitch X using a Y different than 0, for example Y=50, so actually my only solution is to drive square how (0/-50/0, 10/-50/0, 10/-40/0, 0/-40/0, 0/-50/0) and then set object.position.y to 50 so it draw to scene at (0/0/0, 10/0/0, 10/10/0, 10/0/0, 0/0/0) and when I object.Pitch(30) I can se the object rotate in a large circle.
There is a way to move the Y ration fulcrum without move entrire object coordinates ?
Thank you very much
Last edit: shine world 2018-02-06
Hi Silverio i don't understand your question
An object is define by many vertices (in you case 4) if you rotate object, all vertices are rotated. it's a normal behaviour. Remember apply rotation to parent rotate child around. Child object are not independant. so you must travel your parent object and apply rotation to child one by one
Before to insert images or video I will try to explain in another way.
Any object, in my case a TGLLines, can be placed in the scene using its Position property.
Any object can pitch, roll, and turn, but uses always x0:y0:z0 how fulcrum of rotation.
I would like to pitch,roll and turn changing this point, for example in the x10:y12:z3 in a object with with100height100deep100.
I'm using this to rotate a toolpath, stored in TGLLines, in a CNC program.
In CNC system the rotation axis (A) is used to rotate the toolpath and can be placed anywhere in the axes table (not fixed to x0y0z0 of toolpath object).
Thank you very much in advance.
Last edit: shine world 2018-02-07
Ok if i understand well rotation is with arbitary axis. This axis is alway place at 0,0,0 in world space ? or in the ModelSpace ?I see 2 solutions
1st : Have auxiliarry axis based on the object position.
In GLVectorGeometry unit you can find :
in each GLScene'sObject you can find some usefull function and propertie like :
procedure MoveObjectAround(anObject: TGLBaseSceneObject; pitchDelta, turnDelta: Single);
So i think by using MoveObjectAround it will be possible. For example, if i understand you have a toolpath like a simple circle. This Toolpath is alway place at 0,0,0. your object is at 10,15,20.
Solution :
1. Make a copy of the toolpath
2. Move, and rotate the temp toolpath relative to the axis of the object and rotation axis choosen
3. Translate the object along the chosen axis of Circle Toolpath Radius
4. Do a MoveObjectAround
2nd : You need translate your object at 0,0,0 (like in this video i found on subject : https://www.youtube.com/watch?v=yELs34X2UXc )
Make the transformation and replace the objet to initial pos
I hope it will help a little
Thank you for suggestions,
I will try early monday to evaluate this way and show you a resulting video :)
THANK YOU very MUCH !!!
Thank you Jerome.D,
now 4th axis (A) rotate correctly my model also when not placed on x/y/z = 0/0/0.
A little demo of resulting rotation:
https://youtu.be/a4f76WfcFWc
Nice Job, at final how do you do ?
I've traslated all TGLLines vectors with the desired offset in X/Y/Z (model world), so the TGLLines object (scene world) can be moved in scene using same complementary offset in Position.x/y/z property and then I can rotate/turn/pitch :)
Another sample of pitch on X:
https://youtu.be/pa4vNTYA_q8
GLScene is a very amazing tool !!!
Last edit: shine world 2018-02-19
Very very impressive. I have a question what's name of your tool for making video ?
Thank you,
without the help of this site I think I would not have arrived where I am now.
GLSCENE make simple to use OpenGL to everyone and reduce a lot the amount of required code.
I'm using a free software called Open Broadcaster Software, very powerfull !!!
https://obsproject.com/
Last edit: shine world 2018-02-19
Thanks for the link. Wait to see the next generation, you'll can use Lazarus for update your project :).
Hi by finding some in informations, in GLGizmoEx I fell back on top
It's a little late but hey, it's up to you
A +
Last edit: Jerome.D (BeanzMaster) 2018-02-24
Thanks Jerome,
I was far from office for some days and I saw just now your last message.
Wonderful piece of software which can simplify my code.
:)
Thank you so much !!!