Geometry

People are still making stuff for the Sinclair related machines. Tell us about new games and other software that runs on the Spectrum, ZX80/ZX81, Pentagon and Next.
User avatar
zarsoft
Drutt
Posts: 19
Joined: Wed Dec 29, 2021 1:24 pm

Re: Geometry

Post by zarsoft »

ParadigmShifter wrote: Fri Feb 23, 2024 4:36 pm
Next step for geometry would of course be a conversion of this excellent ruler and compass construction tool to the speccy :)
It's tiring without a mouse...
User avatar
ParadigmShifter
Manic Miner
Posts: 671
Joined: Sat Sep 09, 2023 4:55 am

Re: Geometry

Post by ParadigmShifter »

Yeah and basic would not cut it either :) Especially since you get an error if you try and draw a circle or arc which goes outside screen bounds (which is a bit crap really, surely they could have checked the point they are about to plot is on screen and just not plot it if it is not).

EDIT: It could be done with keyboard by only allowing you to place your ruler or compass between 2 already constructed points and start with 2 given points initially (0 and 1) - you are also allowed to place a new point anywhere on a circle as well though (obviously needed to bisect an angle which can be done with ruler and compass), and again for an arbitrary point on a line. You just aren't strictly allowed to measure the length or the angle if you place an arbitrary new point on a line or a circle (although that tool supports that). All you really need to make it work would be algorithms for the intersections of 2 lines, a line and a circle, and intersection points of 2 circles (all well known algorithms, they are all in graphics gems book #1). I think the set of constructed points would grow pretty fast though (probably quadratically).

EDIT2: That tool really needs a way to zoom in or out and rotate the world as well :(
User avatar
ParadigmShifter
Manic Miner
Posts: 671
Joined: Sat Sep 09, 2023 4:55 am

Re: Geometry

Post by ParadigmShifter »

I think this is my favourite geometry formula though

https://en.wikipedia.org/wiki/Shoelace_formula

which calculates the area of any polygon :) It's also pretty simple to code.

Mathologer video about it here



Mechanical device which does the calculation for you

Image

https://en.wikipedia.org/wiki/Planimeter

which can also be used to trace around curved shapes to tell you the area!
User avatar
zarsoft
Drutt
Posts: 19
Joined: Wed Dec 29, 2021 1:24 pm

Re: Geometry

Post by zarsoft »

ParadigmShifter wrote: Fri Feb 23, 2024 6:56 pm I think this is my favourite geometry formula though

One of my favorite formulas is the formula that tells whether the point P(x,y) is inside or outside the triangle ABC.
User avatar
ParadigmShifter
Manic Miner
Posts: 671
Joined: Sat Sep 09, 2023 4:55 am

Re: Geometry

Post by ParadigmShifter »

That's just dot products really (and in 3d, distance to plane which also uses the dot product).

A sexier algorithm is the one which tells you if you are inside an arbitrary shaped polygon... shoot a ray out from where you are in any direction and count how many times you intersect the line segments of the polygon. If it's even you are outside, if it's odd you are inside.

Image
User avatar
zarsoft
Drutt
Posts: 19
Joined: Wed Dec 29, 2021 1:24 pm

Re: Geometry

Post by zarsoft »

ParadigmShifter wrote: Fri Feb 23, 2024 7:44 pm A sexier algorithm is the one which tells you if you are inside an arbitrary shaped polygon...

Nice.
Post Reply