- #1

BrentK

- 21

- 0

Hi All.

I'm new here so I hope you will bear with me and please tell me if this is out of context or in the wrong part of the forum.

I am trying to programm a falling pipe system with corners in ArchiCAD (GDL).

I have been programming in different languages for a while now, but new to 3D vector coordinate programming and never really had to face complex mathmatical challenges like this.

I am hoping you Maths experts will be able to help me with this as I have now spent days trying to get it right and am slowly going crazy!

OK here we go. Hope its not too complicated to explain...

The falling pipe programm includes pipes at varaible lengths, followed by corners or bends at variable angles, in the same fall slope.

Each item (pipe or corner) starts at a coordinate point, then with the given slope and angle calculates the exate end point coordinates in x,y and z, to connect the next item to.

The normal straight pipes are no problem, but I am having trouble calculating the exact end point of the corners.

Here are images showing the current results of my programm (Notice the offset of the last connecting pipe to the 45 degree corner piece)

View attachment 8572

View attachment 8573

Here is the code of the corner item. I tried to comment it as good as possible and hope that it is self explanatary. If something is unclear please feel free to ask me.

Just to clarify, it is the returned coordinates that are not quite right RET_X,RET_Y and RET_Z. I suspect it has to do with the fall in the corner that i can't quite figure out.

Thanks to anyone who can relieve the current pressure on my brain and help me finally figure this out!

I'm new here so I hope you will bear with me and please tell me if this is out of context or in the wrong part of the forum.

I am trying to programm a falling pipe system with corners in ArchiCAD (GDL).

I have been programming in different languages for a while now, but new to 3D vector coordinate programming and never really had to face complex mathmatical challenges like this.

I am hoping you Maths experts will be able to help me with this as I have now spent days trying to get it right and am slowly going crazy!

OK here we go. Hope its not too complicated to explain...

The falling pipe programm includes pipes at varaible lengths, followed by corners or bends at variable angles, in the same fall slope.

Each item (pipe or corner) starts at a coordinate point, then with the given slope and angle calculates the exate end point coordinates in x,y and z, to connect the next item to.

The normal straight pipes are no problem, but I am having trouble calculating the exact end point of the corners.

Here are images showing the current results of my programm (Notice the offset of the last connecting pipe to the 45 degree corner piece)

View attachment 8572

View attachment 8573

Here is the code of the corner item. I tried to comment it as good as possible and hope that it is self explanatary. If something is unclear please feel free to ask me.

Just to clarify, it is the returned coordinates that are not quite right RET_X,RET_Y and RET_Z. I suspect it has to do with the fall in the corner that i can't quite figure out.

Code:

```
!=======================================================================
!Here are the dynamic variables, normally provided by program code or user: ... (HEL = Horizontal Elbow...or corner)
!=======================================================================
HEL_Slope = -10 ! Slope in percent (10 percent is unrealistic but magnifies the angle for testing purposes)
Y_ROT_S = -90 ! Starting rotation in the Y Axis (used to set the rotation position matching the preceding object(pipe))
X_ROT_S = 90 ! Rotation Direction in the X-Axis (Provides the direction in which the following object (pipe)will continue in)
HEL_D = 0.1 ! Dimension of the drainpipe in m (in this case 10cm)
ELBOW_R = HEL_D ! Radius of the corner is the same as the dimension of the pipe
HEL_ROT = 45 ! Angle of the corner (In this case 45 degrees)
!=======================================================================
!Calculate parameters
!=======================================================================
HEL_Slopedegree=ATN(HEL_SLOPE/100) !Turn the percentage slope into slope in degrees (percentage is given because it is standard pipe slope unit)
!=======================================================================
!Apply Rotational values
!=======================================================================
ROTX X_ROT_S !Rotate the corner in the X Axis
ROTZ -(HEL_Slopedegree) !Rotate the corner in the Z Axis (continuing slope of the pipe system)
ROTY Y_ROT_S !Rotate the corner in the Y Axis
!=======================================================================
!Draw the corner
!======================================================================= ELBOW ELBOW_R,HEL_ROT,HEL_D/2 !Call syntax: ELBOW [Radius of corner],[Angle size to draw],[Radius of pipe]
!=======================================================================
! Calculate the exact end coordinates of the corner to place the next piece of the pipe line
! RET_X,RET_Y and RET_Z are the positions that the macro will return to the original programm call
! Here is where I am having problems ! :)!=======================================================================
!New X and Y coordinates:
!------------------------
!Based on the following theory i try and find the new x and y positions
!if the centre of the answer circle is (h,k),angle θ,and radius r,then position of point is
!(h+rcosθ,k+rsinθ)
IF X_ROT_S < 0 THEN
RET_X=-(HEL_D*COS(HEL_ROT))
RET_Y=HEL_D-(HEL_D*SIN(HEL_ROT))
ELSE
RET_X=-(HEL_D*COS(HEL_ROT-.3))
RET_Y=-HEL_D+(HEL_D*SIN(HEL_ROT))
ENDIF
!New Z coordinate:
!------------------------
!To find the difference in height at the given pipe slope I try using pythagoras theory to first find the
!distance "C" between the old and new coordinate (a2+b2=c2)
A=HEL_X-RET_X
B=HEL_Y-RET_Y
C=SQR(A^2+B^2)
RET_Z = C * SIN(HEL_Slopedegree)
```