home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form Form1
- Caption = "Form1"
- ClientHeight = 7770
- ClientLeft = 3600
- ClientTop = 2340
- ClientWidth = 9060
- Height = 8235
- Left = 3540
- LinkTopic = "Form1"
- ScaleHeight = 7770
- ScaleWidth = 9060
- Top = 1935
- Width = 9180
- Begin VB.CommandButton Command12
- Caption = "3D EXAMPLE6"
- Height = 495
- Left = 7560
- TabIndex = 11
- Top = 6720
- Width = 1335
- End
- Begin VB.CommandButton Command11
- Caption = "3D EXAMPLE5"
- Height = 495
- Left = 7560
- TabIndex = 10
- Top = 5400
- Width = 1335
- End
- Begin VB.CommandButton Command10
- Caption = "3D EXAMPLE4"
- Height = 495
- Left = 7560
- TabIndex = 9
- Top = 4080
- Width = 1335
- End
- Begin VB.CommandButton Command9
- Caption = "3D EXAMPLE3"
- Height = 495
- Left = 7560
- TabIndex = 8
- Top = 2760
- Width = 1335
- End
- Begin VB.CommandButton Command8
- Caption = "3D EXAMPLE2"
- Height = 495
- Left = 7560
- TabIndex = 7
- Top = 1440
- Width = 1335
- End
- Begin VB.CommandButton Command7
- Caption = "3D EXAMPLE1"
- Height = 495
- Left = 7560
- TabIndex = 6
- Top = 120
- Width = 1335
- End
- Begin VB.CommandButton Command6
- Caption = "2D EXAMPLE6"
- Height = 495
- Left = 120
- TabIndex = 5
- Top = 6720
- Width = 1335
- End
- Begin VB.CommandButton Command5
- Caption = "2D EXAMPLE5"
- Height = 495
- Left = 120
- TabIndex = 4
- Top = 5400
- Width = 1335
- End
- Begin VB.CommandButton Command4
- Caption = "2D EXAMPLE4"
- Height = 495
- Left = 120
- TabIndex = 3
- Top = 4080
- Width = 1335
- End
- Begin VB.CommandButton Command3
- Caption = "2D EXAMPLE3"
- Height = 495
- Left = 120
- TabIndex = 2
- Top = 2880
- Width = 1335
- End
- Begin VB.CommandButton Command2
- Caption = "2D EXAMPLE 2"
- Height = 495
- Left = 120
- TabIndex = 1
- Top = 1440
- Width = 1335
- End
- Begin VB.CommandButton Command1
- Caption = "2D EXAMPLE 1"
- Height = 495
- Left = 120
- TabIndex = 0
- Top = 120
- Width = 1335
- End
- Attribute VB_Name = "Form1"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Dim Shared Shape2D(2000, 2) As Single
- Dim Shared Shape3D(2000, 3) As Single
- Dim Shared Object3D(2000)
- Sub Draw2D(Obj As Integer, Colr As Integer)
- ' Obj = entry number in Shape2D
- ' Colr = QBColor number
- i = Obj
- PSet (Shape2D(i, 1), Shape2D(i, 2))
- i = i + 1
- Line -(Shape2D(i, 1), Shape2D(i, 2)), QBColor(Colr)
- Loop Until Shape2D(i + 1, 1) = 9999
- Line -(Shape2D(Obj, 1), Shape2D(Obj, 2)), QBColor(Colr)
- End Sub
- Sub Pitch(OldObj As Integer, CentreX As Single, CentreY As Single, CentreZ As Single, Angle As Single)
- ' OldObj = input number in Shape3D
- ' CentreX = X ordinate of centre
- ' CentreY = Y ordinate or centre
- ' CentreZ = Z ordinate or centre
- ' Angle = Degrees of rotation anticlockwise
- ' assign variable rather than repeat calculation
- SinY = Sin(Angle * 0.0174533)
- CosY = Cos(Angle * 0.0174533)
- i = OldObj - 1
- ' process each point on the shape
- i = i + 1
- j = Object3D(i) - 1
- Do
- j = j + 1
- OldX = Shape3D(j, 1) - CentreX
- OldY = Shape3D(j, 2) - CentreY
- OldZ = Shape3D(j, 3) - CentreZ
- Shape3D(j, 2) = OldY * CosY - OldZ * SinY + CentreY
- Shape3D(j, 3) = OldY * SinY + OldZ * CosY + CentreZ
- Loop Until Shape3D(j + 1, 1) = 9999
- Loop Until Object3D(i + 1) = 9999
- End Sub
- Sub Sketch(Obj As Integer, Colr As Integer, Alpha As Single, Phi As Single)
- ' Obj = entry number in Object3D
- ' Colr = QBColor number
- ' Alpha = attack angle to horizon (passed inward)
- ' Phi = vantage angle (passed inward)
- Dim i, j As Integer
- i = Obj
- j = Object3D(i)
- Draw3D j, Colr, Alpha, Phi
- i = i + 1
- Loop Until Object3D(i) = 9999
- End Sub
- Sub Draw3D(Obj As Integer, Colr As Integer, Alpha As Single, Phi As Single)
- ' Obj = entry number in Shape2D
- ' Colr = QBColor number
- ' Alpha = attack angle to horizon
- ' Phi = vantage angle
- Dim NewX As Single, NewY As Single, OrigX As Single, OrigY As Single
- Dim TanAlpha As Single, Length As Single
- TanAlpha = Tan(Alpha * 0.0174533)
- i = Obj
- GoSub Resolve
- OrigX = NewX: OrigY = NewY
- PSet (OrigX, OrigY)
- i = i + 1
- GoSub Resolve
- Line -(NewX, NewY), QBColor(Colr)
- Loop Until Shape3D(i + 1, 1) = 9999
- Line -(OrigX, OrigY), QBColor(Colr)
- Exit Sub
- Resolve:
- X = Shape3D(i, 1)
- Y = Shape3D(i, 2)
- Z = Shape3D(i, 3)
- If Abs(TanAlpha) < 0.01 Then
- Length = 0
- Else
- Length = Z / TanAlpha
- End If
- NewX = X + Length * Cos(Phi * 0.0174533)
- NewY = Y + Length * Sin(Phi * 0.0174533)
- Return
- End Sub
- Sub Enlarge2D(OldObj As Integer, NewObj As Integer, CentreX As Single, CentreY As Single, Factor As Single)
- ' OldObj = input number in Shape2D
- ' NewObj = output number in Shape2D
- ' CentreX = X ordinate of centre of enlargement
- ' CentreY = Y ordinate or centre of enlargement
- ' Factor = Enlargement (>1) or Shrinkage (<1) factor
- i = OldObj - 1
- j = NewObj - 1
- ' process each point on the shape
- i = i + 1
- j = j + 1
- Shape2D(j, 1) = (Shape2D(i, 1) - CentreX) * Factor + CentreX
- Shape2D(j, 2) = (Shape2D(i, 2) - CentreY) * Factor + CentreY
- Loop Until Shape2D(i + 1, 1) = 9999
- ' add a drogue to output
- Shape2D(j + 1, 1) = 9999
- End Sub
- Sub Rotate2D(OldObj As Integer, NewObj As Integer, CentreX As Single, CentreY As Single, Angle As Single)
- ' OldObj = input number in Shape2D
- ' NewObj = output number in Shape2D
- ' CentreX = X ordinate of centre of enlargement
- ' CentreY = Y ordinate or centre of enlargement
- ' Angle = Degrees of rotation anticlockwise
- ' assign variable rather than repeat calculation
- SinX = Sin(Angle * 0.0174533)
- CosX = Cos(Angle * 0.0174533)
- i = OldObj - 1
- j = NewObj - 1
- ' process each point on the shape
- i = i + 1
- j = j + 1
- OldX = Shape2D(i, 1) - CentreX
- OldY = Shape2D(i, 2) - CentreY
- Shape2D(j, 1) = OldX * CosX - OldY * SinX + CentreX
- Shape2D(j, 2) = OldX * SinX + OldY * CosX + CentreY
- Loop Until Shape2D(i + 1, 1) = 9999
- Shape2D(j + 1, 1) = 9999
- End Sub
- Sub Roll(OldObj As Integer, CentreX As Single, CentreY As Single, CentreZ As Single, Angle As Single)
- ' OldObj = input number in Shape3D
- ' CentreX = X ordinate of centre
- ' CentreY = Y ordinate or centre
- ' CentreZ = Z ordinate or centre
- ' Angle = Degrees of rotation anticlockwise
- ' assign variable rather than repeat calculation
- SinX = Sin(Angle * 0.0174533)
- CosX = Cos(Angle * 0.0174533)
- i = OldObj - 1
- ' process each point on the shape
- i = i + 1
- j = Object3D(i) - 1
- Do
- j = j + 1
- OldX = Shape3D(j, 1) - CentreX
- OldY = Shape3D(j, 2) - CentreY
- OldZ = Shape3D(j, 3) - CentreZ
- Shape3D(j, 1) = OldX * CosX - OldY * SinX + CentreX
- Shape3D(j, 2) = OldX * SinX + OldY * CosX + CentreY
- Loop Until Shape3D(j + 1, 1) = 9999
- Loop Until Object3D(i + 1) = 9999
- End Sub
- Sub Move2D(OldObj As Integer, NewObj As Integer, XChange As Single, YChange As Single)
- ' OldObj = input number in Shape2D
- ' NewObj = output number in Shape2D
- ' XChange = amount of movement along X axis
- ' YChange = amount of movement along Y axis
- i = OldObj - 1
- j = NewObj - 1
- ' process each point on the shape
- i = i + 1
- j = j + 1
- Shape2D(j, 1) = Shape2D(i, 1) + XChange
- Shape2D(j, 2) = Shape2D(i, 2) + YChange
- Loop Until Shape2D(i + 1, 1) = 9999
- Shape2D(j + 1, 1) = 9999
- End Sub
- Sub X3Reset()
- BackColor = QBColor(10)
- Scale (-50, 50)-(50, -50)
- For i = 1 To 2000
- Object3D(i) = 9999
- Shape3D(i, 1) = 9999
- End Sub
- Sub XCrosshairs(CentreX As Single, CentreY As Single)
- ' draw crosshairs
- DrawWidth = 2
- Line (CentreX, CentreY + 2)-(CentreX, CentreY - 2)
- Line (CentreX + 2, CentreY)-(CentreX - 2, CentreY)
- End Sub
- Sub X2Reset()
- BackColor = QBColor(10)
- Scale (-50, 50)-(50, -50)
- For i = 1 To 2000
- Shape2D(i, 1) = 9999
- Line (-100, 0)-(100, 0), QBColor(0)
- Line (0, -100)-(0, 100), QBColor(0)
- End Sub
- Sub XSetShape2D()
- ' set up the shape
- Shape2D(1, 1) = 0: Shape2D(1, 2) = 0
- Shape2D(2, 1) = 10: Shape2D(2, 2) = 0
- Shape2D(3, 1) = 20: Shape2D(3, 2) = 10
- Shape2D(4, 1) = 20: Shape2D(4, 2) = 20
- Shape2D(5, 1) = 10: Shape2D(5, 2) = 30
- Shape2D(6, 1) = 0: Shape2D(6, 2) = 30
- Shape2D(7, 1) = -10: Shape2D(7, 2) = 20
- Shape2D(8, 1) = -10: Shape2D(8, 2) = 10
- End Sub
- Sub XSetShape3D()
- ' set up the pyramid shape
- ' first side
- Shape3D(1, 1) = 20
- Shape3D(1, 2) = 0
- Shape3D(1, 3) = 20
- Shape3D(2, 1) = -20
- Shape3D(2, 2) = 0
- Shape3D(2, 3) = 20
- Shape3D(3, 1) = 0
- Shape3D(3, 2) = 40
- Shape3D(3, 3) = 0
- 'second side
- Shape3D(5, 1) = 20
- Shape3D(5, 2) = 0
- Shape3D(5, 3) = 20
- Shape3D(6, 1) = 20
- Shape3D(6, 2) = 0
- Shape3D(6, 3) = -20
- Shape3D(7, 1) = 0
- Shape3D(7, 2) = 40
- Shape3D(7, 3) = 0
- 'third side
- Shape3D(9, 1) = 20
- Shape3D(9, 2) = 0
- Shape3D(9, 3) = -20
- Shape3D(10, 1) = -20
- Shape3D(10, 2) = 0
- Shape3D(10, 3) = -20
- Shape3D(11, 1) = 0
- Shape3D(11, 2) = 40
- Shape3D(11, 3) = 0
- 'fourth side
- Shape3D(13, 1) = -20
- Shape3D(13, 2) = 0
- Shape3D(13, 3) = 20
- Shape3D(14, 1) = -20
- Shape3D(14, 2) = 0
- Shape3D(14, 3) = -20
- Shape3D(15, 1) = 0
- Shape3D(15, 2) = 40
- Shape3D(15, 3) = 0
- 'fifth side
- Shape3D(17, 1) = -20
- Shape3D(17, 2) = 0
- Shape3D(17, 3) = 20
- Shape3D(18, 1) = -20
- Shape3D(18, 2) = 0
- Shape3D(18, 3) = -20
- Shape3D(19, 1) = 20
- Shape3D(19, 2) = 0
- Shape3D(19, 3) = -20
- Shape3D(20, 1) = 20
- Shape3D(20, 2) = 0
- Shape3D(20, 3) = 20
- 'declare the 3D shape
- Object3D(1) = 1
- Object3D(2) = 5
- Object3D(3) = 9
- Object3D(4) = 13
- Object3D(5) = 17
- 'set up the cube shape
- ' first side
- Shape3D(22, 1) = -20
- Shape3D(22, 2) = 20
- Shape3D(22, 3) = 20
- Shape3D(23, 1) = -20
- Shape3D(23, 2) = -20
- Shape3D(23, 3) = 20
- Shape3D(24, 1) = -20
- Shape3D(24, 2) = -20
- Shape3D(24, 3) = -20
- Shape3D(25, 1) = -20
- Shape3D(25, 2) = 20
- Shape3D(25, 3) = -20
- 'second side
- Shape3D(27, 1) = -20
- Shape3D(27, 2) = 20
- Shape3D(27, 3) = 20
- Shape3D(28, 1) = 20
- Shape3D(28, 2) = 20
- Shape3D(28, 3) = 20
- Shape3D(29, 1) = 20
- Shape3D(29, 2) = 20
- Shape3D(29, 3) = -20
- Shape3D(30, 1) = -20
- Shape3D(30, 2) = 20
- Shape3D(30, 3) = -20
- 'third side
- Shape3D(32, 1) = 20
- Shape3D(32, 2) = 20
- Shape3D(32, 3) = 20
- Shape3D(33, 1) = 20
- Shape3D(33, 2) = -20
- Shape3D(33, 3) = 20
- Shape3D(34, 1) = 20
- Shape3D(34, 2) = -20
- Shape3D(34, 3) = -20
- Shape3D(35, 1) = 20
- Shape3D(35, 2) = 20
- Shape3D(35, 3) = -20
- 'fourth side
- Shape3D(37, 1) = 20
- Shape3D(37, 2) = -20
- Shape3D(37, 3) = 20
- Shape3D(38, 1) = 20
- Shape3D(38, 2) = -20
- Shape3D(38, 3) = -20
- Shape3D(39, 1) = -20
- Shape3D(39, 2) = -20
- Shape3D(39, 3) = -20
- Shape3D(40, 1) = -20
- Shape3D(40, 2) = -20
- Shape3D(40, 3) = 20
- 'fifth side
- Shape3D(42, 1) = -20
- Shape3D(42, 2) = 20
- Shape3D(42, 3) = 20
- Shape3D(43, 1) = 20
- Shape3D(43, 2) = 20
- Shape3D(43, 3) = 20
- Shape3D(44, 1) = 20
- Shape3D(44, 2) = -20
- Shape3D(44, 3) = 20
- Shape3D(45, 1) = -20
- Shape3D(45, 2) = -20
- Shape3D(45, 3) = 20
- 'sixth side
- Shape3D(47, 1) = -20
- Shape3D(47, 2) = 20
- Shape3D(47, 3) = -20
- Shape3D(48, 1) = 20
- Shape3D(48, 2) = 20
- Shape3D(48, 3) = -20
- Shape3D(49, 1) = 20
- Shape3D(49, 2) = -20
- Shape3D(49, 3) = -20
- Shape3D(50, 1) = -20
- Shape3D(50, 2) = -20
- Shape3D(50, 3) = -20
- 'declare the 3D shape
- Object3D(7) = 22
- Object3D(8) = 27
- Object3D(9) = 32
- Object3D(10) = 37
- Object3D(11) = 42
- Object3D(12) = 47
- End Sub
- Sub Yaw(OldObj As Integer, CentreX As Single, CentreY As Single, CentreZ As Single, Angle As Single)
- ' OldObj = input number in Shape3D
- ' CentreX = X ordinate of centre
- ' CentreY = Y ordinate or centre
- ' CentreZ = Z ordinate or centre
- ' Angle = Degrees of rotation anticlockwise
- ' assign variable rather than repeat calculation
- SinX = Sin(Angle * 0.0174533)
- CosX = Cos(Angle * 0.0174533)
- i = OldObj - 1
- ' process each point on the shape
- i = i + 1
- j = Object3D(i) - 1
- Do
- j = j + 1
- OldX = Shape3D(j, 1) - CentreX
- OldY = Shape3D(j, 2) - CentreY
- OldZ = Shape3D(j, 3) - CentreZ
- Shape3D(j, 1) = OldX * CosX - OldZ * SinX + CentreX
- Shape3D(j, 3) = OldX * SinX + OldZ * CosX + CentreZ
- Loop Until Shape3D(j + 1, 1) = 9999
- Loop Until Object3D(i + 1) = 9999
- End Sub
- Private Sub Command1_Click()
- X2Reset
- XSetShape2D
- XCrosshairs 10, -15
-
- For i = 1 To 80
- DrawWidth = 1: Draw2D 1, 4
- Move2D 1, 1, -0.7, 2.5
- Enlarge2D 1, 1, 10, -15, 0.95
- DrawWidth = 2: Draw2D 1, 4
- End Sub
- Private Sub Command10_Click()
- X3Reset
- XSetShape3D
- ' pyramid
- Sketch 1, 0, 60, 40
- For i = 1 To 5
- Pitch 1, 0, 0, 0, 5
- Sketch 1, 12, 60, 40
- Sketch 1, 1, 60, 40
- End Sub
- Private Sub Command11_Click()
- X3Reset
- XSetShape3D
- ' pyramid
- Sketch 1, 0, 60, 40
- For i = 1 To 5
- Yaw 1, 0, 0, 0, 5
- Sketch 1, 12, 60, 40
- Sketch 1, 1, 60, 40
- End Sub
- Private Sub Command12_Click()
- X3Reset
- XSetShape3D
- ' pyramid
- Roll 1, 0, 0, 0, 70
- Pitch 1, 0, 0, 0, 160
- Yaw 1, 0, 0, 0, 30
- Sketch 1, 12, 60, 40
- End Sub
- Private Sub Command2_Click()
- X2Reset
- XSetShape2D
- XCrosshairs 10, -15
-
- For i = 1 To 80
- DrawWidth = 1: Draw2D 1, 4
- Move2D 1, 1, -0.3, -2.4
- Enlarge2D 1, 1, 10, -15, 1.02
- DrawWidth = 2: Draw2D 1, 4
- End Sub
- Private Sub Command3_Click()
- X2Reset
- XSetShape2D
- XCrosshairs -10, 20
-
- For i = 1 To 80
- DrawWidth = 1: Draw2D 1, 4
- Move2D 1, 1, -0.3, -0.2
- Enlarge2D 1, 1, -10, 20, 1.005
- DrawWidth = 2: Draw2D 1, 4
- End Sub
- Private Sub Command4_Click()
- X2Reset
- XSetShape2D
- XCrosshairs 5, 15
-
- For i = 1 To 80
- DrawWidth = 1: Draw2D 1, 4
- Enlarge2D 1, 1, 5, 15, 1.01
- DrawWidth = 2: Draw2D 1, 4
- End Sub
- Private Sub Command5_Click()
- X2Reset
- XSetShape2D
- XCrosshairs 5, 15
-
- For i = 1 To 80
- DrawWidth = 1: Draw2D 1, 4
- Enlarge2D 1, 1, 5, 15, 0.99
- DrawWidth = 2: Draw2D 1, 4
- End Sub
- Private Sub Command6_Click()
- X2Reset
- XSetShape2D
-
- DrawWidth = 2: Draw2D 1, 1
- Move2D 1, 1, 5, 15
- DrawWidth = 2: Draw2D 1, 4
- Move2D 1, 1, -17, -20
- Rotate2D 1, 1, 30, -30, 17
- DrawWidth = 2: Draw2D 1, 14
- End Sub
- Private Sub Command7_Click()
- X3Reset
- XSetShape3D
- ' cube
- Sketch 7, 1, 70, -20
- End Sub
- Private Sub Command8_Click()
- X3Reset
- XSetShape3D
- ' pyramid
- Sketch 1, 12, 60, 40
- End Sub
- Private Sub Command9_Click()
- X3Reset
- XSetShape3D
- ' pyramid
- Sketch 1, 0, 60, 40
- For i = 1 To 5
- Roll 1, 0, 0, 0, 5
- Sketch 1, 12, 60, 40
- Sketch 1, 1, 60, 40
- End Sub
- Private Sub Form_Load()
- X3Reset
- End Sub
- Private Sub Form_Paint()
- Line (-100, 0)-(100, 0), QBColor(0)
- Line (0, -100)-(0, 100), QBColor(0)
- End Sub
-