GDL
About building parametric objects with GDL.

Hotspot rotation example that rotates horizontally and vertically

Domagoj Lukinic
Booster

Hi all!

Can someone proved me with an example code of 2 hotspots that rotate horizontally and vertically

For example you have a box that you rotate 35 degrees horizontally and then rotate it 35 degrees vertically (hotspot follows rotation)

 

Thank you in advance!

5 REPLIES 5
Barry Kelly
Moderator

The problem is you do not want to rotate the horizontal hotspot code (ROTz) horizontally but you do want to rotate it vertically.

And you don't want to rotate the vertical hotspot code (ROTx) vertically but you do want to rotate it horizontally.

And you actual object you want to rotate both.

 

So, just thinking out load without actually testing it myself, you would need to ...

 

ROTz   !!rotate vertical hotspot horizontally only

code for vertical hotspot

DEL 1

 

ROTx    !!rotate horizontal hotspot vertically only

code for horizontal hotspot

DEL 1

 

ROTz

ROTx

code for object

DEL 1

DEL 1

 

 

I think.

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Lingwisyer
Guru

Is the movement dependant or independant? And you are wanting to define them by angle given a set distance?

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660

Yes.

I want to define both rotation by variable, moving hotspot is at a fixed distance lets say at  A,0 (End of box) and vertical hotspot is at A/2,0 (half length of box)  but when I change the angle, moving hotspot needs to be at that location (see code) the problem is when I set vertical rotation my horizontal plane is wrong. I am imputing the wrong coordinates but I do not know anymore how to it 😅

material mat1
rotz verticalRot
roty horizontalRot
addy -0.5/2
hotspot	0,0,0
hotspot	0,0.5,0
hotspot	0,0,0.25
block 1,0.5,0.25
del top

unID=000


!=== HORIZONTAL ROTATION ===!
hotspot	COS(verticalRot),SIN(verticalRot),0, unID, horizontalRot, 4: unID = unID + 1                                      			                                                    !--- BASE
hotspot	COS(verticalRot)*COS(horizontalRot)*0.5,SIN(verticalRot)*COS(horizontalRot)*0.5,-TAN(horizontalRot)*COS(horizontalRot)*0.5, unID, horizontalRot, 5: unID = unID + 1		!--- MOVEING
hotspot	0,0,0, unID, horizontalRot, 6: unID = unID + 1																												                        !--- CENTAR
	angleForRefence=verticalRot+90
hotspot COS(angleForRefence)*5,SIN(angleForRefence)*5,0, unID, horizontalRot,7: unID = unID + 1																				                        !--- REFERENCE
!=== HORIZONTAL ROTATION ===!

!=== VERTICAL ROTATION ===!
hotspot	5,0,-TAN(horizontalRot)*COS(horizontalRot), unID, verticalRot, 4+128: unID = unID + 1                                      						                !--- BASE
hotspot	COS(verticalRot)*COS(horizontalRot),SIN(verticalRot)*COS(horizontalRot),-TAN(horizontalRot)*COS(horizontalRot), unID, verticalRot, 5: unID = unID + 1     !--- MOVEING
hotspot	0,0,-TAN(horizontalRot), unID, verticalRot, 6: unID = unID + 1                                           						                !--- CENTAR
hotspot	0,0,5, unID, verticalRot, 7: unID = unID + 1    
!=== VERTICAL ROTATION ===!                                         															                    !--- REFERENCE

This is better.

The two hotspots need different radii, other wise you will only be able to select one of them.

The inner one is horizontal and the outer one is vertical.

I cheated and rotated the horizontal hotspot script and just substituted the vertical parameter.

 

material mat1
roty verticalRot
rotz horizontalRot
hotspot	0,0,0
add -0.5, -0.25, -0.125
block 1,0.5,0.25
del 1
del 1
del 1

unID=000


roty verticalRot
!=== HORIZONTAL ROTATION ===!
hotspot	0,0,0, unID, horizontalRot, 6: unID = unID + 1													!--- CENTAR
hotspot	0.5,0,0, unID, horizontalRot, 4: unID = unID + 1                                      			!--- BASE
hotspot	COS(horizontalRot)*0.25,SIN(horizontalRot)*0.25,0, unID, horizontalRot, 5: unID = unID + 1		!--- MOVEING
hotspot 0,0,1, unID, horizontalRot,7: unID = unID + 1			!--- REFERENCE
!=== HORIZONTAL ROTATION ===!
del 1

rotz horizontalRot
rotx -90
!=== VERTICAL ROTATION ===!
hotspot	0,0,0, unID, verticalRot, 6: unID = unID + 1													!--- CENTAR
hotspot	0.5,0,0, unID, verticalRot, 4: unID = unID + 1                                      			!--- BASE
hotspot	COS(verticalRot)*0.30,SIN(verticalRot)*0.30,0, unID, verticalRot, 5: unID = unID + 1		!--- MOVEING
hotspot 0,0,1, unID, verticalRot,7: unID = unID + 1			!--- REFERENCE
!=== VERTICAL ROTATION ===!
del 1
del 1

 

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Lingwisyer
Guru

If stacking angle hotspots does not work, you could script intermediate x, y and z parameters that feed back into the angles.

 

Barry, your vertical reference axis needs to shift for the given horizontal rotation else the hotspot vs object rotation axis do not match. Adjusting the base, reference and sometimes centre hotspot in relation to a different transformation is a pain...

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!