To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cad.devOpen lugnet.cad.dev in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / Development / 1014
1013  |  1015
Subject: 
Re: baseplate 32 x 32 road curve with road pattern-9 studs
Newsgroups: 
lugnet.cad.dev
Date: 
Tue, 6 Apr 1999 14:12:34 GMT
Viewed: 
1366 times
  
On Tue, 6 Apr 1999 08:25:45 GMT, "jonathan wilson" <wilsonj@xoommail.com> wrote:

i know that the torus generator generated part looks kind of shit but i know
nothing about circular maths (trig?). steve tells me that the helipad and road
curve 7 studs have both been made with the generator... have you seen those yet
tery? do they suffer the same problems?

I didn't use the torus generator program on the new parts.  I wrote a couple of Visual Basic
routines that I used on the new pieces, which generate circular rings and edges.  I've included the
routines below, but I haven't done anything to package these up for people who aren't VB
programmers.  If you have VB, you can use these routines by copying them to a standard module,
running your project, hitting Break, and invoking the routines from the Immediate window.

BTW, I used iStep=16 in the parts I did, which is only 4x the resolution of the existing LDraw
primitives (that's a hint to the primitive committee).  It looks pretty good, but the line segments
can be seen on the curved-road plate.

Steve

=== VB Routines follow =============================
' GenEdge and GenTorus are the two routines to call directly.
' Example (entered in Immediate window):
'    ? GenEdge(100, 0, pi/2, 24, 32)
'    ? GenEdge(150, 0, pi/2, 24, 32)
'    ? GenTorus(100, 150, 0, pi/2, 16, 32)

Public Const Pi = 3.14159265358979

Public Type P3D
   X As Double
   Y As Double
   Z As Double
End Type

Public Function GenEdge(ByVal Radius As Single, ByVal StartAngle As Single, _
                        ByVal StopAngle As Single, ByVal C As Single, _
                        ByVal iStep As Long) _
   As String

' Generate polygonal approximation of a circular arc with center (0,0,0), in the XZ plane,
' radius Radius, color C, between StartAngle and StopAngle, with iStep segments.
   Dim Theta As Single
   Dim IA As P3D
   Dim IB As P3D
   Dim i As Long
   Dim iStepCount As Long
   Dim sBuf As String

   IA.X = Radius * Cos(StartAngle)
   IA.Y = 0
   IA.Z = Radius * Sin(StartAngle)

   sBuf = ""

   For i = 1 To iStep
      Theta = StartAngle + i * (StopAngle - StartAngle) / iStep
      IB.X = Radius * Cos(Theta)
      IB.Z = Radius * Sin(Theta)

      sBuf = sBuf & "2 " & C & " " & FormatTriple(IA) & FormatTriple(IB) & vbCrLf

      IA = IB
   Next i

   GenEdge = sBuf
End Function

Public Function GenTorus(ByVal InnerRadius As Single, ByVal OuterRadius As Single, _
                     ByVal StartAngle As Single, ByVal StopAngle As Single, ByVal C As Single, _
                     ByVal iStep As Long) _
   As String
' Generate approximation of circular torus section with center (X,0,Z), inner radius
' InnerRadius, outer radius OuterRadius and color C, with iStep segments.
' The generated figure will lie in the positive Z half-plane.
   Dim Theta As Single
   Dim IA As P3D
   Dim IB As P3D
   Dim OA As P3D
   Dim OB As P3D
   Dim i As Long
   Dim iStepCount As Long
   Dim sBuf As String

   IA.X = InnerRadius * Cos(StartAngle)
   IA.Y = 0
   IA.Z = InnerRadius * Sin(StartAngle)
   OA.X = OuterRadius * Cos(StartAngle)
   OA.Y = 0
   OA.Z = OuterRadius * Sin(StartAngle)

   sBuf = ""

   For i = 1 To iStep
      Theta = StartAngle + i * (StopAngle - StartAngle) / iStep
      IB.X = InnerRadius * Cos(Theta)
      IB.Z = InnerRadius * Sin(Theta)
      OB.X = OuterRadius * Cos(Theta)
      OB.Z = OuterRadius * Sin(Theta)

      sBuf = sBuf & "4 " & C & " " & FormatTriple(IA) & FormatTriple(IB) _
           & FormatTriple(OB) & FormatTriple(OA) & vbCrLf

      IA = IB
      OA = OB
   Next i

   GenTorus = sBuf
End Function

Public Function FormatTriple(A As P3D) As String
   FormatTriple = NumStr(A.X) & BLANK & NumStr(A.Y) & BLANK & NumStr(A.Z) & BLANK
End Function

Public Function NumStr(ByVal nVal As Single) As String
   Dim iTemp As Long

   iTemp = nVal * 1000
   If iTemp = 0 Then
      NumStr = "0"
   Else
      NumStr = Trim$(Str$(iTemp / 1000))
   End If
End Function



Message has 1 Reply:
  Re: baseplate 32 x 32 road curve with road pattern-9 studs
 
thanks for the vb routines. do i have your permission to package them into a utillity for the ldraw parts making community at large? i amy be writing it in delphi (converting your algorithim to delphi in the process). it will be called ldcg (ldraw (...) (25 years ago, 7-Apr-99, to lugnet.cad.dev)

Message is in Reply To:
  Re: baseplate 32 x 32 road curve with road pattern-9 studs
 
i know that the torus generator generated part looks kind of shit but i know nothing about circular maths (trig?). steve tells me that the helipad and road curve 7 studs have both been made with the generator... have you seen those yet tery? do they (...) (25 years ago, 6-Apr-99, to lugnet.cad.dev)

32 Messages in This Thread:











Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR