Results 1 to 16 of 16

Thread: 3D field

Threaded View

  1. #1

    Thread Starter
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860

    Angry 3D field

    Hi, I'm trying to make a 3D field in QBasic, and I'm having a few problems. Mainly in 2 functions (I think).

    VB Code:
    1. Sub Movement (X,Y,Z,Speed,Angle1, Angle2)
    2. 'angle1 is XY direction, angle2 is Z direction (supposedly)
    3. 'Sin(0) = 1 and Cos(90) = 1 right???
    4. X = X + Speed* Sin(Angle1) * Cos(Angle2)
    5. Y = Y + Speed * Cos(Angle1) * Cos(Angle2)
    6. Z = Z + Speed * Cos(Angle1) * Sin(Angle2)
    7. End sub
    8.  
    9. Sub Placement (X,Y,Z)
    10. 'This assumes your viewpoint doesn't move, to start
    11.  
    12. '(I have a function for angles)
    13. AngleXY = Angle from 0,0 to X,Y
    14.  
    15. Diagonal = Sqr((X^2) + (Y^2))
    16. 'Get difference on x,y axises
    17. Distance = Sqr((Diagonal^2) + (Z^2))
    18. 'A^2 + B^2 = C^2, I use this to set the size
    19. TrueAngle = anglesub(0,0,Diagonal,Z)
    20. 'I use this with the XY angle to place the object
    21.  
    22. TargetX = 320 + (((TrueAngle) / 90) * 320) * Sin(AngleXY)
    23. TargetY = 240 + (((TrueAngle) / 90) * 320) * Cos(AngleXY)
    24. 'Use TrueAngle and XYangle to place, expand to fit screen size
    25. '240 is the center of Y, 320 is center of X, (320,240)=centerscreen
    26.  
    27. '*****Set size of object here, change color to grey if FAR*****
    28. 'Sorry bout not including size code.. its not important
    29.  
    30. 'Draw the point...
    31. Circle(TargetX, TargetY), Size, Color
    32. Paint(TargetX, TargetY), Color
    33. End Sub

    Any ideas?
    Last edited by alkatran; Dec 11th, 2002 at 03:20 PM.
    Don't pay attention to this signature, it's contradictory.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width