Physics Simulation
- 2 Devlogs
- 3 Total hours
A physics simulation experiment, written in Go
A physics simulation experiment, written in Go
I’ve been working on my physics simulation and I had to convert between two coordinate systems (world space and screen space). My brain really struggled with this one for some reason.
After spending some time trying to work it out in code I gave up and had to create a drawing in Freeform and literally draw out and rescale the vectors, moving them to where they needed to be.
So that’s what this screenshot is! I’ll explain what everything means.
Basically, everything in my engine is a 2D vector. I have a point in world space (represented as a vector of course) and need to convert it to screen space, but they have different origins (center vs top left). The idea is to display it as if it was world space but on the screen. The arrows are me physically placing, moving, and scaling the vectors to find the pattern that converts them.
Anyways, that was hard haha. It broke my brain
I just finished setting up the project to use “ebiten,” a UI library for Go. Additionally, I created a type Vector2D struct with an X and Y as well as Add, Subtract, Scale, Dot, and Rotate methods.
Unfortunately, I don’t have any interesting images to put here, so here’s a screenshot of the vector code :)