LOL you know those dreams you have this brilliant idea and then awake you realize the folly and say, "What was I thinking?"
I can do the ellipse without trig but I need the trig in Point rotation for tilt:
I can do the ellipse without trig but I need the trig in Point rotation for tilt:
Code: (Select All)
_Title "Experiment with Ellipse" 'b+ 2023-07-04
Type xy
As Single x, y
End Type
Screen _NewImage(800, 600, 32)
_ScreenMove 250, 60
For tilt = 0 To 360 Step .25
Line (0, 0)-(_Width, _Height), &H05000000, BF
drawTiltedEllipse 400, 300, 250, 150, tilt, &HFFFFFF00
_Limit 30
Next
Sub drawTiltedEllipse (xc, yc, xRadius, yRadius, Tilt, clr~&)
ReDim a(xRadius * 4) As xy
r2 = xRadius * xRadius
fit = yRadius / xRadius
For x = xRadius To -xRadius Step -1
y = fit * Sqr(r2 - x ^ 2)
a(i).x = xc + x
a(i).y = yc + y
'PSet (a(i).x, a(i).y), clr~&
i = i + 1
Next
For x = -xRadius + 1 To xRadius
y = fit * Sqr(r2 - x ^ 2)
a(i).x = xc + x
a(i).y = yc - y
'PSet (a(i).x, a(i).y), clr~&
i = i + 1
Next
ReDim _Preserve a(i - 1) As xy
Dim temp As xy
Rotate 400, 300, a(0).x, a(0).y, Tilt, temp
PSet (temp.x, temp.y), &HFF0000FF
For i = LBound(a) + 1 To UBound(a)
Rotate 400, 300, a(i).x, a(i).y, Tilt, temp
Line -(temp.x, temp.y), &HFF0000FF
Next
End Sub
Sub Rotate (cx, cy, x, y, degAng, a As xy)
'cx, cy is center of rotation
'x, y the point to rotate
'degAng the angle in degrees to rotate
' output a.X, a.Y ' our point of rotation
d = _Hypot(cx - x, cy - y) ' distance between xc and x
ang = _Atan2(y - cy, x - cx)
a.x = cx + d * Cos(ang + _D2R(degAng))
a.y = cy + d * Sin(ang + _D2R(degAng))
End Sub
b = b + ...