Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ugh. Is my math (and logic) right?
#4
Works for me after I make it right with QB64:
Code: (Select All)
Screen _NewImage(641, 201, 32)


For X = 0 To 640 Step 10
    MyLine 0, 0, X, 200
Next X
For Y = 0 To 200 Step 5
    Line (0, 0)-(640, Y), _RGB(255, 255, 0)
Next Y
Sub MyLine (x1%, y1%, x2%, y2%)
    ' y% = m# * x% + c#
    xd% = x2% - x1%
    yd% = y2% - y1%
    m# = yd% / xd%
    c# = y2% - x2% * m#
    If xd% >= yd% Then For i = x1% To x2%: PSet (i, m# * i + c#): Next i
    If xd% < yd% Then For i = y1% To y2%: PSet ((i - c#) / m#, i): Next i
End Sub

And faster than my method! Nice if it works for all x, y
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Messages In This Thread
Ugh. Is my math (and logic) right? - by CharlieJV - 08-29-2023, 12:47 AM
RE: Ugh. Is my math (and logic) right? - by bplus - 08-29-2023, 01:12 AM
RE: Ugh. Is my math (and logic) right? - by bplus - 08-29-2023, 02:00 AM
RE: Ugh. Is my math (and logic) right? - by bplus - 08-29-2023, 12:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  random maze map. math help pmackay 4 553 08-10-2025, 11:22 AM
Last Post: pmackay
  Is my Logic wrong or QB64's ? bplus 10 2,150 10-15-2023, 09:04 PM
Last Post: James D Jarvis
  Compiler setting for accurate math? James D Jarvis 12 2,447 12-01-2022, 10:16 PM
Last Post: Pete
  Any math experts know what I'm missing here? [Solved] Pete 24 4,092 09-26-2022, 07:00 PM
Last Post: Kernelpanic

Forum Jump:


Users browsing this thread: 1 Guest(s)