Archive for November 11th, 2009

Hyperbolic Paraboloids – math model

Wednesday, November 11th, 2009

Hyperbolic paraboloids (HP) are discribed by the formula
\frac{x^2}{a^2} - \frac{y^2}{b^2} - 2z = 0
The below script creates HPs in Microstation within a certain range of  x and y coordinates. The dashed lines indicate the regular grid on coordinate system. These are of parabolic shape. The thick diagonal lines are all straight. They are the reason why this shape is interesting for construction, as it can be discribed as a series of straight lines. Intersecting the surface with a horizontal plane creates hyperbolas (blue curves).

Hyperbolic paraboloid

Hyperbolic paraboloid

‘Hyperbolic Paraboloids
‘Sebastian Gmelin
’11.11.2009

Const a As Double = 2
Const b As Double = 2

Const range As Long = 8

Dim hp() As Point3d

Dim x As Double
Dim y As Double
Dim z As Double
   
Dim point As Point3d

Dim ele As element
Sub drawGrid()

Dim points() As Point3d

ReDim points(range * 2)

    For x = range * -1 To range
        For y = range * -1 To range
            points(y + range) = hp(x + range, y + range)
        Next y
        Set ele = CreateLineElement1(Nothing, points)
        ele.Color = 4
        ele.LineWeight = 0
        ActiveModelReference.AddElement ele
        ele.Redraw
    Next x
   
    For y = range * -1 To range
        For x = range * -1 To range
            points(x + range) = hp(x + range, y + range)
        Next x
        Set ele = CreateLineElement1(Nothing, points)
        ele.Color = 4
        ele.LineWeight = 0
        ActiveModelReference.AddElement ele
        ele.Redraw
    Next y

End Sub
Sub drawDiaGrid()

Dim points() As Point3d
Dim i As Long

    For i = 1 To range * 2
        x = range * -1
        ReDim points(i)
        For y = range – i To range
            points(y – range + i) = hp(x + y + i, y + range)
        Next y
        Set ele = CreateLineElement1(Nothing, points)
        ele.Color = 7
        ele.LineWeight = 1
        ActiveModelReference.AddElement ele
        ele.Redraw
       
        For y = i To 0 Step -1
            points(i – y) = hp(i – y, y)
        Next y
        Set ele = CreateLineElement1(Nothing, points)
        ele.Color = 7
        ele.LineWeight = 1
        ActiveModelReference.AddElement ele
        ele.Redraw
       
        If i < range * 2 Then
            y = range * -1
            ReDim points(range * 2 – i)
            For x = range * -1 + i To range
                points(x + range – i) = hp(x + range, y + range * 2 + x – i)
            Next x
            Set ele = CreateLineElement1(Nothing, points)
            ele.Color = 7
            ele.LineWeight = 1
            ActiveModelReference.AddElement ele
            ele.Redraw
           
            y = range
            ReDim points(range * 2 – i)
            For x = range * -1 + i To range
                points(x + range – i) = hp(x + range, y – x + i)
            Next x
            Set ele = CreateLineElement1(Nothing, points)
            ele.Color = 7
            ele.LineWeight = 1
            ActiveModelReference.AddElement ele
            ele.Redraw
        End If
    Next i
   
   
End Sub

Sub horizontalCut(cz As Double)

Dim points() As Point3d
Dim pointsNeg() As Point3d

ReDim points(range * 2)
ReDim pointsNeg(range * 2)
   
    If cz >= 0 Then
        For y = range * -1 To range
            x = Math.Sqr(a * a * (((y * y) / (b * b)) + 2 * cz))
            points(y + range) = Point3dFromXYZ(x, y, cz)
            pointsNeg(y + range) = Point3dFromXYZ(-1 * x, y, cz)
        Next y
    Else
        For x = range * -1 To range
            y = Math.Sqr(b * b * (((x * x) / (a * a)) – 2 * cz))
            points(x + range) = Point3dFromXYZ(x, y, cz)
            pointsNeg(x + range) = Point3dFromXYZ(x, -1 * y, cz)
        Next x
    End If

    Set ele = CreateLineElement1(Nothing, points)
    ele.Color = 5
    ele.LineWeight = 2
    ActiveModelReference.AddElement ele
    ele.Redraw
   
    Set ele = CreateLineElement1(Nothing, pointsNeg)
    ele.Color = 5
    ele.LineWeight = 2
    ActiveModelReference.AddElement ele
    ele.Redraw

End Sub

 

Sub Main()
   
    ReDim hp(range * 2, range * 2)
   
    For x = range * -1 To range
        For y = range * -1 To range
            z = (((x * x) / (a * a)) – ((y * y) / (b * b))) / 2
            point = Point3dFromXYZ(x, y, z)
            Set ele = CreateLineElement2(Nothing, point, point)
            ele.Color = 3
            ele.LineWeight = 10
            ActiveModelReference.AddElement ele
            ele.Redraw
            hp(x + range, y + range) = point
        Next y
    Next x
   
    drawGrid
    drawDiaGrid
    horizontalCut (range / 2)
    horizontalCut (range / -2)

End Sub

Share