Ugh. Is my math (and logic) right? - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://staging.qb64phoenix.com/forumdisplay.php?fid=10) +---- Thread: Ugh. Is my math (and logic) right? (/showthread.php?tid=1944) Pages:
1
2
|
Ugh. Is my math (and logic) right? - CharlieJV - 08-29-2023 Such a long time since I've done this kind of stuff, I don't have much confidence in my struggled result. Is this the right way to draw a line with PSET ??? Code: (Select All) SCREEN _NEWIMAGE(641, 201, 32) RE: Ugh. Is my math (and logic) right? - SMcNeill - 08-29-2023 Why not just draw a line with LINE? RE: Ugh. Is my math (and logic) right? - CharlieJV - 08-29-2023 (08-29-2023, 12:59 AM)SMcNeill Wrote: Why not just draw a line with LINE? Because I'm working on something that doesn't work with LINE. (Or with DRAW.) That wee bit of code is just the first bit. RE: Ugh. Is my math (and logic) right? - bplus - 08-29-2023 Works for me after I make it right with QB64: Code: (Select All) Screen _NewImage(641, 201, 32) And faster than my method! Nice if it works for all x, y RE: Ugh. Is my math (and logic) right? - SMcNeill - 08-29-2023 Probably needs division by zero logic for horizontal and vertical lines. RE: Ugh. Is my math (and logic) right? - CharlieJV - 08-29-2023 (08-29-2023, 01:12 AM)bplus Wrote: Works for me after I make it right with QB64: Ok, math seems to makes sens. I was really unsure. Now to tackle vertical and horizontal lines. RE: Ugh. Is my math (and logic) right? - bplus - 08-29-2023 Oh I hadn't setup my method correctly it's fast too comparing bLine to MyLine Code: (Select All) Screen _NewImage(800, 600, 32) RE: Ugh. Is my math (and logic) right? - CharlieJV - 08-29-2023 (08-29-2023, 02:00 AM)bplus Wrote: Oh I hadn't setup my method correctly it's fast too comparing bLine to MyLine I had started with something more like bline, but I was really not sure of myself, and went the other way. I much prefer bline. I will steal that. RE: Ugh. Is my math (and logic) right? - CharlieJV - 08-29-2023 @bplus Now I remember part of my concern with my first approach: distance of the line between two points yielding decimal values that cause loss of a pixel at the end of a line. Here's what I'm getting (white lines being MyLine(), yellow lines being bline: RE: Ugh. Is my math (and logic) right? - CharlieJV - 08-29-2023 And the instant I posted that last one, wait a minute ... Problem solved with a little security (last two lines added to bLine): Code: (Select All) Sub bLine (x1, y1, x2, y2) |