DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

dome math

Started by wgwade, May 16, 2011, 09:26:29 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wgwade

Dome math.
File "dome.d3m",  All the math done in Liberty Basic v4.04. Then put the data into "dome.d3m".
This is a complete drawing with shading.
File" dome2.d3m", Runs, draws "X" only.
File "dome1.d3m", Runs to line 32 and stops, draws "X" only.
The math in "dome.d3m"  and "dome1.d3m"  are correct, in "dome2.d3m"  the math will give the wrong data when run in Design Cad, most of the X and Y are zero
If you have or can get a copy of Liberty Basic from,  http://www.libertybasic.com/download.html
And run  the file "octa.txt", change txt to bas then you will see the data that I use in "dome.bas"
I am hope that someone can help me fix the math so that it will work in a Design Cad macro, without using Liberty Basic.
I am 70 I completed  High School in 1956 my math is a little rusty. Thank you Bill.

Dempsey

I had a look at dome1.d3m and split up the multi-statement IFs and that got the macro executing much further.

However, there is something wrong with the first calculation at label 140: and I simply don't see the error.

Sorry, it is past midnight for me and I am heading for bed.

Dempsey

Lar

Not sure what I did different from Dempsey but I got the macro to finish (mine is not as tidy as Dempsey's). However, all it does is the 'X', 4 flat 3-point lines all in the same place (points 1 and 3 are in the same place), a pointed line shaped like a thin arrow (points 3 is slightly above point 1) and an identical plane. Maybe the positions of some of the 'end if's should be moved down a line.... (later) I moved them with the exact same result. Anyway, now that it ends you can check what it's supposed to do.

My adjustments are below. If you run the macro once so that the screen gets zoomed on where the action takes place THEN delete everything then run it again (keeping the same zoom) you will see the stuff being created (it will seem like only 1 flat line was drawn since they are all in the same place).

Lar

CLS' dome1, by W.Wade
'dome1 by wgwade-Lar's adjustments-17May11.d3m
'--------------------
a = 1.5707963275 '90 Degrees in Radians
f = 2 'Frequency of dome (1 - 8)
vx = 0
vy = 0 'Offset XYZ
vz = 0
'---------------
sx = 50
sy = 50 'Scale XYZ
sz = 50
'---------------
sys(36) = 1
sys(33) = 1
sys(800) = 2
precision 8
'---------------
>Text
{
<Color 0, 0, 0
<Font "Simplex_Win"
<Text "X"
<Size 1
<pointxyz [0,0,50]
}
'----------------

FOR z=f TO 1 step -1
FOR a1=0 TO f-z
          b1=f-(a1+z)
          c1=f-(a1+b1)
          IF a1+b1=0 THEN px=0
tx=0
GOTO 110
end if
          IF a1=f THEN px=a
tx=a
GOTO 110
end if
          IF b1=0 THEN px=a
GOTO 100
''''end if
          px=atn(a1/b1)
'''''
end if

100:
          tx=atn(((a1^2+b1^2)^.5)/c1)

110:
          IF a1+b1=f THEN tx=a
          IF b1=f THEN px=0
          a2=a1+1
          c2=c1-1
          b2=f-(a2+c2)
          IF a2=f THEN py=a
ty=a
GOTO 130
end if
          IF b2=0 THEN py=a
GOTO 120
'''''end if
          py=atn(a2/b2)
end if

120:
          IF c2=0 THEN ty=atn((a2^2+b2^2)^.5)
ELSE ty=atn(((a2^2+b2^2)^.5)/c2)
end if

130:
          IF a2+b2=f THEN ty=a
          IF b2=f THEN py=0
          a3=a2-1
          c3=c2
          b3=f-(a3+c3)
          IF a3=f THEN pz=a
tz=a
GOTO 150
end if
          IF b3=0 THEN pz=a
GOTO 140
''''end if
          pz=atn(a3/b3)
end if

140:
          IF c3=0 THEN tz=atn((a3^2+b3^2)^.5)
ELSE tz=atn(((a3^2+b3^2)^.5)/c3)
end if

150:
          IF a3+b3=f THEN tz=a
          IF b3=f THEN pz=0

          GOSUB 200
     NEXT a1
NEXT z

>FitToWindow
{
}

END

200:
     rx=1
     ry=1
     rz=1

     x1=rx*(sin(tx)*cos(px))
     y1=rx*(sin(tx)*sin(px))  ' Point "X" on triangle
     z1=rx*(cos(tx))

     x2=ry*(sin(ty)*cos(py))
     y2=ry*(sin(ty)*sin(py))  ' Point "Y" on triangle
     z2=ry*(cos(ty))

     x3=rz*(sin(tz)*cos(pz))
     y3=rz*(sin(tz)*sin(pz))  ' Point "Z" on triangle
     z3=rz*(cos(tz))

     x1=x1*sx
     y1=y1*sy     
     z1=z1*sz

     x2=x2*sx     
     y2=y2*sy 'Scale of triangle
     z2=z2*sz

     x3=x3*sx
     y3=y3*sy
     z3=z3*sz

    >LINE
    {
    <Color 0,0,0
    <POINTXYZ [x1,y1,z1]
    <POINTXYZ [x2,y2,z2]
    <POINTXYZ [x3,y3,z3]
    <POINTXYZ [x1,y1,z1]
    }

    >PLANE
    {
    <POINTXYZ [x1,y1,z1]
    <POINTXYZ [x2,y2,z2]
    <POINTXYZ [x3,y3,z3]
    <POINTXYZ [x1,y1,z1]
    }

    RETURN


wgwade

Thank you, Lar's, when I run it, I see what you mean, it's not a dome.
Bill.

Dempsey

wgwade,

I am back again, found the error(s) and corrected the attached dome1.d3m.


  • atn is treated as an array (got the error message now) and I changed that to the correct atan function.
  • Got also very little in terms of drawn results, so I changed f=2 to f=8, and that at least generated a quarter of the dome.
  • Before exiting a macro it is always good to reset SYS(36)=0 and SYS(800)=0, which I added too.

Dempsey

wgwade

Dempsey, thank you. Yours is much better. With f set to 8 (Frequency) it seem to draw the first six levels, then goes wrong. Also the top of the dome has moved away from the "x".
I am going to work on this, to see if I can fix it. I renamed dome1 to dome3.

wgwade

I worked on "dome3.d3m" for a number of hours. I cannot get it to work the right way. For now I will go back to using Liberty Basic to draw the domes. Thank you every one, for all the help.
Regards Bill.