479
Relaxing (lemmy.world)
you are viewing a single comment's thread
view the rest of the comments
[-] lightnegative@lemmy.world 15 points 2 months ago* (last edited 2 months ago)

This was me for years.

And then I had to write some software that needed to visualise a rotary milking platform which is a circle, divided into segments, with different parts of each segment showing different things at different times.

Oh, and since it's rotary, the circle had to be animated and rotate in sync with the actual milking platform.

Oh and different clients had different numbers of bays in their platforms so I couldn't hardcode anything, it had to dynamically draw the platform, animate it and respond to events like window size change.

Suffice to say I had to drag highschool geometry out from the graveyard of my brain

[-] refalo@programming.dev 1 points 2 months ago

Any code you can share? I'm interested in finally learning how to apply some simple geometry maths to my programming, but I failed math in school.

[-] Buddahriffic@lemmy.world 3 points 2 months ago

Check out 3d graphics related stuff, there's a ton of geometry used there, whether you're ray tracing or using 2d projection.

A ray tracer is basically made up of:

  • ray caster algorithm to map pixels to rays and puts them into an image
  • data structures to contain scene data (like geometry, lighting, materials)
  • algorithm that represents a ray as a line and determines which parts of the scene geometry that line intersects with, selecting the one nearest and in front of the eye (or wherever the front is culled)
  • same algorithm used to determine if a ray from that intersection point to each light has anything between the point and light
  • also need to get the angle to the light for each ray that isn't blocked
  • a shading algorithm that uses the lights, materials, and angles (and maybe more info) to determine the colour of that ray
  • some code that does something with the resulting image, like display it or save to a file

And that's basically it. It will be slow without optimizations but it's cool af seeing your renders. And you can improve on it from there if you want. Though a warning: you might get obsessed with analysing different visual phenomena and thinking about how to render something like that for a while after doing this, which might also lead to gaining a critical eye for where 3d engines fail to be accurate.

this post was submitted on 01 May 2024
479 points (89.6% liked)

Funny: Home of the Haha

4841 readers
658 users here now

Welcome to /c/funny, a place for all your humorous and amusing content.

Looking for mods! Send an application to Stamets!

Our Rules:

  1. Keep it civil. We're all people here. Be respectful to one another.

  2. No sexism, racism, homophobia, transphobia or any other flavor of bigotry. I should not need to explain this one.

  3. Try not to repost anything posted within the past month. Beyond that, go for it. Not everyone is on every site all the time.


Other Communities:

founded 1 year ago
MODERATORS