Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Circle rotation in space. Can't calculate x coordinate.

Anonymous
Not applicable
I'm trying to make a circle that has a center in origo. Se the illustration below.
I first put the circle on the horizontal layer (XY-layer and z=0). Center is origo (x=y=z=0) That works fine.
I tilt the circle with an angle to the horizontal layer. I call this angleXY.
The circle cuts through the horizontal layer in the X-axis. The circle is tilted counter-clockwise. This also works fine.
But the problem occures when I try to rotate the tilted circle counterclockwise around the z-axis. The angle is vinkeXZ. I can't figure out how to calculate the x-coordinates. I 've tryed many formulas, but the coordinates eighter give me an ellipsis or a line.

Here is the code (vinkel norwegian for angle):

fromDegrees = 10
toDegrees = 360
stepDegrees = 10
centerX = 0
centerY = 0
centerZ = 0
radiusP = 0.5
vinkelXZ = 45 ! Angle from the X-axis counterclockwise around the Z-axis (centerX and centerY=0)
vinkelXY = 45 ! Angle between the horizontal-layer and the circle.
! Counterclockwise around the X-axis (centerY=0)
angle = 0
GOSUB "GenerateCircularCoordinates"


END


"GenerateCircularCoordinates":
! This routine calculates xyz-coordinates to a circle that tilts against the horizontal-layer
! and rotates around the Z-axis
!
! Calculate the trigonometric factores to angles that do not change in the loop.
sinVinkelXY = SIN(vinkelXY)
cosVinkelXY = COS(vinkelXY)
sinVinkelXZ = SIN(vinkelXZ)
cosVinkelXZ = COS(vinkelXZ)

FOR vinkel = fromDegrees TO toDegrees STEP stepDegrees
deltaX = radiusP * COS (vinkel)
deltaY = radiusP * SIN (vinkel)
deltaZ = radiusP * SIN (vinkel)

x = centerX - deltaX
y = centerY - deltaY
z = centerZ
! ---------------------------------------------------
! Tilt against the horizontal-layer (XY-layer)
! Rotation around the X-axis
!
z = -y * sinVinkelXY + centerZ
y = y * cosVinkelXY + centerY
! ---------------------------------------------------
! Rotation around the Z-axis
!
y = y + x*sinVinkelXZ
x = x*cosVinkelXZ
!
! PUT x, y, z, angle
IF vinkel <> 0 THEN
ADD x, y, z
TEXT 0.005, 0, vinkel
DEL 1
LIN_ x - 0.01, y - 0.01, z - 0.01, x + 0.01, y + 0.01, z + 0.01
ENDIF

NEXT vinkel
RETURN

CircleIll.jpg
12 REPLIES 12
Anonymous
Not applicable
Hi Anne,

Perhaps I'm missing something...

Do you know you can use the Circle command in 3d?...

Its in the GDL Reference Manual Page 61.

HTH.
Anonymous
Not applicable
Yes, I forgot to tell why I want to make this routine.
I will use the TUBE and SWEEP commands in GDL.
Instead of splitting the object I want to make into different parts, rotating axis a.s.o., I want to generate the x,y,z coordinates for the path, put it into the internal array, and fetch them when I use the TUBE and SWEEP commands. So that's the background. So it's actually the coordinates I need to generate, not the circle.
Anonymous
Not applicable
Ok Anne... Let me see if I get it right...

You want to Generate xyz coordinates of a circle/arc and this circle/arc has to be rotated in the xyz axis with no distortion, right?

At first it makes me wonder why not generate the coords in the xy plan an rotate it using transformations (RotX, RotY, RotZ)?
Anonymous
Not applicable
I want the axis to be in the same position all the time. I want to find the coordinates with the axis as a reference. It means I cannot rotate the axis.
I just need a formula for calculating the X-coordinate. I think it's actually a matehematic problem.
Aussie John
Newcomer
Anne wrote:
I want the axis to be in the same position all the time. I want to find the coordinates with the axis as a reference. It means I cannot rotate the axis.
I just need a formula for calculating the X-coordinate. I think it's actually a matehematic problem.
Cant you just DEL the ROT transformation to return the axis to a default position.
Cheers John
John Hyland : ARINA : www.arina.biz
User ver 4 to 12 - Jumped to v22 - so many options and settings!!!
OSX 10.15.6 [Catalina] : Archicad 22 : 15" MacBook Pro 2019
[/size]
Anonymous
Not applicable
As John well said, if you use DEL after the ROT the axis will return to its place...

But I can see by your code that you perfectly know how to use ROT AND DEL...

Sorry Anne, but I really can't understand why you can't use a simple transformation.

Perhaps if you could describe us whats the final purpose of the object we could help more effectively.

HTH.
Anonymous
Not applicable
The original purpose was to make a scarf that is hanging over a horizontal pole. I will use the TUBE or SWEEP commands in GDL to optain this. Do you know those commands?
(I want an alternative to splitting the object I want to make into different parts, rotating axis, adding distances in different directions a.s.o.)
The path I need consists of parts of a circe, orientated in different ways in the space, and with different radiuses and centerpoints, all attached to eachother.
So, that is why I want to make a routine like this.
I want to generate the x,y,z coordinates for the path, put it into the internal array, and fetch them when I use the TUBE and SWEEP commands. In that way it will be much more easy to make those difficult objects, I think. And I can simply reuse this routine over and over again.
This is the background.
Anonymous
Not applicable
Ok... Now I get it. Its a tuff geometry...

Do you know Andrew Watson's "GDL Handbook"?

In page 251 it has a wonderful 3d cubic spline that would do the job with more smooth and realistic effect.

Sorry I can't help you more.
Anonymous
Not applicable
No, unfourtunately I do not have that book. But, I bought the GDL Cookbook 3. some time ago. I've looked through it, but could not find anything like this, as far as I could see.
I tested out my husbands brain yesterday. But his solution creates another interesting shape . A friend of me told me today that her husband was really good in mathematics, so I have to test him 😉