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?

# Vector maths and whatnot

**Botisaurus**(Boti Kis) #2

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.

**Botisaurus**(Boti Kis) #4

But it isnāt I promise! Itās super easy to digest.

The first chapter vectors alone should cover your questions.

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

**Pharap**(Pharap) #7

Thanks for the mention, I hadnāt got round to reading this thread yet.

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ā.)

**Kea_Oliver**(Kea Oliver) #8

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 )

**Pharap**(Pharap) #9

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.)

**Kea_Oliver**(Kea Oliver) #10

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.

**Pharap**(Pharap) #11

Which libraries are you thinking of?

Or do you just mean it doesnāt have any vector libraries available in general?

**Kea_Oliver**(Kea Oliver) #12

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.

**Pharap**(Pharap) #13

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.

**Kea_Oliver**(Kea Oliver) #14

ā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.

**Freezingsnail**#15

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

**Pharap**(Pharap) #16

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.)