# Vector maths and whatnot

So I was watching a video on someone making a doom 3d engine style thing and it looked pretty interesting, however he was using vector mathematics and matrices which I have basically no understanding of. Wondered if anyone on here has any experience or links towards good resources for learning this kind of thing?

1 Like

The book I always recommend is the nature of code.

It explains the math of physics in super easy, understandable and fast way.
The book begins with basic math explaining what vectors are and moves on to more complex algorithms. Every step is followed by easy understandable code samples in simple java.
You will have no trouble to follow if you speak C(++).

There is a physical release which you can get on amazon but the whole book is available online.

2 Likes

Looks like a hefty tomeā¦ but thanks!

But it isnāt I promise! Itās super easy to digest.
The first chapter vectors alone should cover your questions.

2 Likes

Thanks, ill give it a go!

1 Like

I didnāt check the other book linked but if you check a library for linear algebra books they occasionally will have code in them for each topic as well. You might need an older book though, mine had no code examples and the department recommended one had Matlab I think.

Then again you can probably find c examples for any topic faster on the internet, Wikipedia or stack overflow ect.

I can do a lot of it on paper but not in code.

If I remember right @pharap linked a couple of vids on vectors somewhere for character movement and thereās also at least 2 raycasting doom-lite engines for the arduboy as well

1 Like

The video series can be found here.
He discusses other stuff in later videos (like A* pathfinding),
so if you want to focus on just vectors the playlist for the simple vector stuff is here and the playlist for the advanced vector stuff is here.

(If you ever lose the link again, itās in my ever-handy resource collection.)

As many will know, I usually prefer written articles to youtube videos,
but this is one of those rare cases where I recommend a video series.

I really like this series because Jorge dedicates a video to each aspect of vector arithmetic and ties it to a real-world situation.
(By which I mean a use-case in the context of a video game.)

He explains:

• Vector subtraction in terms of finding the difference between two positions
• Vector magnitude (length) in terms of finding the distance between two positions
• A common videogame speedhack where the square of the magnitude is used instead of the actual magnitude
• (It cuts out the expensive square root)
• Vector multiplication with a scalar
• Unit vectors
• Vector addition in terms of character movement

(@Kea_Oliver, I apologise for all the people saying āmathā instead of āmathsā.)

1 Like

More useful info, i appreciate this too, between books and articles i found and videos Iāve been linked Iām sure I can put something together.

(@Pharap itās fine I forgive them )

1 Like

If itās not just the theory youāre interested in and youāre planning to actually include some vector stuff in one of your games, let me know and I can give you some tips.

(Iāve written half a dozen different vector and matrix implementations over the years.)

Im a very easily distracted person, I was planning on POSSIBLY including something in one of my games and due to the arduboy not having access to any of the libraries to make this stuff super easy I decided I would at least learn some cursory stuff, whether This actually becomes a game or anything is up in the air.

1 Like

Which libraries are you thinking of?
Or do you just mean it doesnāt have any vector libraries available in general?

I should have been more accurate in that my only existing experience with any sort of 3d graphics has been within things like Unity which abstracts it WAYYYYYY out.

Ah, that explains a lot.

This is one of the reasons Iām not a big fan of Unity.
It makes it easy to get things up and running,
but it makes it too easy to avoid having to learn the details.

I take it that means you know a fair bit of C#?

I suddenly remembered another good resource. My favourite maths website!

https://www.mathsisfun.com/algebra/vectors.html

In general I hate maths and mathematicians because practically every maths explanation on the internet is overcomplicated and assumes too much foreknowledge.

āMaths is funā is an oasis in the dessert.

āknewā would be more accurate, I havent programmed anything in a good few years and a lot of what I did know has vanished. You are dead on about maths sites though, finding a basic overview of something can be tricky.

1 Like

Once you embrace the numbers into your being theyāre not as bad.

Until the next day when you fall down another hole and suddenly all the numbers are missing and thereās only words and squigglies

2 Likes

Well, you managed to write something that uses bitshifting, so it canāt have all vanished.

Yeah.

I think itās because historically the people who did maths were mostly wealthy well-educated people who liked to use Greek and Latin in their maths texts to show off how clever they were. `:P`

The numbers I can live with, itās the endless over-formality and the dictionary of obscure mathematical terms that you have to carry around.

My favourite example is āAn Elementary Treatise on Determinantsā by Charles Dodgson.
(Or āLewis Carrollā as you may know him.)

(Unrelated: his uncle had an excellent name. āRobert Wilfred Skeffington Lutwidgeā, who was a āComissioner in Lunacyā. Honestly, you couldnāt make this stuff up if you tried.)

1 Like