Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. Option Explicit
  2. Public Type m3Point
  3. x As Double
  4. y As Double
  5. Z As Double
  6. 'w = 1
  7. End Type
  8. Public Function m3PointInit(ByVal x As Double, ByVal y As Double, ByVal Z As Double) As m3Point
  9. Dim p As m3Point
  10. p.x = x
  11. p.y = y
  12. p.Z = Z
  13. m3PointInit = p
  14. End Function
  15. Public Sub m3PointApply(ByRef p As m3Point, ByRef m As m3Matrix)
  16. Dim x As Double
  17. Dim y As Double
  18. Dim Z As Double
  19. x = p.x
  20. y = p.y
  21. Z = p.Z
  22. p.x = x * m.m11 + y * m.m21 + Z * m.m31 + m.m41
  23. p.y = x * m.m12 + y * m.m22 + Z * m.m32 + m.m42
  24. p.Z = x * m.m13 + y * m.m23 + Z * m.m33 + m.m43
  25. End Sub
  26. Public Function m3PointToString(ByRef p As m3Point) As String
  27. m3PointToString = Format(p.x, "0.00") & vbTab & Format(p.y, "0.00") & vbTab & Format(p.Z, "0.00") & vbTab & "1"
  28. End Function
  29. Public Sub m3PointDraw(ByRef canvas As Object, ByRef p As m3Point)
  30. Dim d As Double
  31. Dim y As Double
  32. Dim x As Double
  33. Dim f As Double
  34. d = Camera3D.getDistance()
  35. f = d / (d - p.Z)
  36. x = p.x * f
  37. y = p.y * f
  38. canvas.Circle (x, y), 3
  39. End Sub
  40. Public Sub m3PointDrawLine(ByRef canvas As Object, ByRef p1 As m3Point, ByRef p2 As m3Point)
  41. Dim x1 As Double
  42. Dim y1 As Double
  43. Dim x2 As Double
  44. Dim y2 As Double
  45. Dim d As Double
  46. Dim f As Double
  47. d = Camera3D.getDistance
  48. f = d / (d - p1.Z)
  49. x1 = f * p1.x
  50. y1 = f * p1.y
  51. f = d / (d - p2.Z)
  52. x2 = f * p2.x
  53. y2 = f * p2.y
  54. canvas.Line (x1, y1)-(x2, y2)
  55. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement