Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Orbit Demo SIN and COS
#2
to use orbit imagine standing at point X_Origin, Y_Origin face towards Degrees direction and move forward Radius length

xOut, yOut are the coordinates of where you are after the move.

here is a simple pentagram made from 5 turns and moves
Code: (Select All)
_Title "orbit demo make pentagram " 'b+ 2024-05-10
Const Xmax = 700, Ymax = 700
Screen _NewImage(Xmax, Ymax, 32)
x = _Width / 2: y = _Height / 2 ' start in center of screen
pentAngle = 72 ' the angles inside a pentagram are 360 / 5 = 72 degrees
forward = 100
For turn = 1 To 5 ' turn
    orbit x, y, Angle, forward, nextx, nexty
    Line (x, y)-(nextx, nexty)
    Angle = Angle + pentAngle ' the absolute angle from 0 degrees accumulates at every turn
    x = nextx: y = nexty
    _Limit 2
Next
'      !!!!!!   featuring the use of this SUB routine   !!!!
Sub orbit (X_Origin, Y_Origin, Degrees, Radius, xOut, yOut) ' all default single  should be ok
    xOut = X_Origin + Radius * Cos(_D2R(Degrees))
    yOut = Y_Origin + Radius * Sin(_D2R(Degrees))
End Sub

a little mod and we have a pentagram spiral
Code: (Select All)
_Title "orbit demo make pentagram spiral " 'b+ 2024-05-10
Const Xmax = 700, Ymax = 700
Screen _NewImage(Xmax, Ymax, 32)
x = _Width / 2: y = _Height / 2 ' start in center of screen
pentAngle = 72 ' the angles inside a pentagram are 360 / 5 = 72 degrees
forward = 10
angle = -36
While y > 0 And y < _Height
    orbit x, y, angle, forward, nextx, nexty
    Line (x, y)-(nextx, nexty)
    forward = forward + 10
    angle = angle + pentAngle ' the absolute angle from 0 degrees accumulates at every turn
    x = nextx: y = nexty '      restart where we left off
    _Limit 2
Wend
'      !!!!!!   featuring the use of this SUB routine   !!!!
Sub orbit (X_Origin, Y_Origin, Degrees, Radius, xOut, yOut) ' all default single  should be ok
    xOut = X_Origin + Radius * Cos(_D2R(Degrees))
    yOut = Y_Origin + Radius * Sin(_D2R(Degrees))
End Sub
b = b + ...
Reply


Messages In This Thread
Orbit Demo SIN and COS - by bplus - 05-17-2024, 03:59 PM
RE: Orbit Demo SIN and COS - by bplus - 05-17-2024, 04:10 PM
RE: Orbit Demo SIN and COS - by bplus - 06-05-2024, 06:12 PM
RE: Orbit Demo SIN and COS - by NakedApe - 06-05-2024, 07:16 PM



Users browsing this thread: 1 Guest(s)