Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Central equation of the ellipse
#1
Code: (Select All)


Screen _NewImage(1000, 1000, 32)

cx = 500 'center x and center y
cy = 500

m = 200 'X radius
n = 100 'y radius

Dim col As _Unsigned Long

For oy = 250 To 750 'ox, oy points in rectangle. If the point is part of an ellipse, it will be white, otherwise it will be black
    For ox = 250 To 750
        aa = ((ox - cx) ^ 2) / m ^ 2
        bb = ((oy - cy) ^ 2) / n ^ 2
        If aa + bb < 1 Then col = _RGB32(255) Else col = _RGB32(0)
        PSet (ox, oy), col
    Next
Next


I often use point detection in a circle, this can easily be modified to detect a point in an ellipse. Maybe it will be useful for someone.


Reply


Messages In This Thread
Central equation of the ellipse - by Petr - 03-19-2024, 09:10 PM
RE: Central equation of the ellipse - by Pete - 03-20-2024, 03:14 AM



Users browsing this thread: 1 Guest(s)