Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I realize this is a fairly common-type question, but I've been studying Maths in my spare time, fairly slowly at that, and I really want to develop a raycasting engine like the original DOOM.

I know more-or-less the subjects / categories of Maths needed for modern 3D games, such as Linear Algebra, but I don't they all would be applicable for a raycasting engine.

Assume I am starting from the ground-up in Maths, what would I need to know? I assume Algebra, Trigonometry and Geometry would be the most important. I'm wondering if I could pull it off just with that?

share|improve this question
    
It seems like you should be asking about how to create a raycasting engine, and then doing research on the math you don't know to solve a problem that you're currently facing rather than just studying math without context. –  Tetrad Jul 12 '12 at 15:49
    
Obligatory: Write Games, Not Engines. (scientificninja.com/blog/write-games-not-engines) An engine is a fine way of trying to learn the technology you want to learn, but a directed purpose for an engine - that is, a game (or even 'just' a visualization) attached to it - will both help motivate during the sloggier bits of development and also actively help with making design decisions for the engine, because you'll be solving a specific problem rather than an abstract one. –  Steven Stadnicki Jul 12 '12 at 18:26
    
@Tetrad I have done some degree of research in raycasting engines, so I know it seems like I'm shooting this question out of the dark, but I have looked at it some. The reason I am asking this question is because I started losing myself a bit when the stuff I was reading got a bit... too Mathy? However, the parts that talked about shooting rays and scaling slices just as Tapio mentioned, seemed to make perfect and simple sense. –  Daniel Carvalho Jul 12 '12 at 19:00

2 Answers 2

Well, if you stick to something very simple then you can do it using only basic linear algebra. I would list the absolute necessities as understanding a) orthogonal coordinate systems; b) matrix multiplication and c) how and why the two are related.

And if you want to actually construct some arbitrary rotation matrices then you'll at least need to understand the basic trigonometric functions and their relation to the circle.

The wikipedia page for Transformation matrix summarizes pretty much everything, and the links from that page has even more information (see 3D projection in particular).

There's also some amount of non-mathematical understanding required of course. If you want to put something together on your own then figuring out how and why to do something might require quite a lot of logical thinking, even when the math in question would turn out to be trivial (which might turn out to be most of the time).

However, I'd say that the most important skill isn't math but the ability to search for information. There is a lot of material in books and on the internet. If there is something you don't understand when reading then you can be quite certain that there are articles and books (or Stack Exchange for that matter) available to explain.

[Edit] Right... It seems I've misunderstood the question, and overshot terribly. See above for a better aimed answer :)

share|improve this answer
2  
what is matrix math used exactly exept for maybe rotation in 2D? raycasting to me is just a bunch of trigonometry. in practice it should be high school mathematics. –  dreta Jul 12 '12 at 8:25
    
Thanks for your time and effort though. It is appreciated. –  Daniel Carvalho Jul 12 '12 at 19:09

A Wolfenstein-style raycaster is really simple. You basically shoot beams horizontally in an arc from one side of the player view to the other edge. When a beam encounters a wall, you get the wall slices height on screen from the distance (e.g. scale_factor / distance). E.g. for this height calculation you don't need to understand anything about matrices etc, just think that you want a smaller height on screen when the distance from viewer is greater.

The "trickiest" part is "shooting" the beam (i.e. determining direction and traversing it in small steps), but that's trivial for any 2d game programmer - just use sin and cos as you would have done for the player movement.

It gets slightly more complicated when adding stuff like textured walls (still easy) and sprite enemies, and you can always explain the thing with difficult mathematics using projection planes and whatnot, but the basic idea is just traversing 2d beams on a 2d grid - if you're language/programming environment has an easy way to output graphics, you can get a basic raycaster running in less than 50 lines of code without any matrices or even vector classes.

share|improve this answer
    
For the research I did do into raycasting engines, I took away what you're saying here, which is very comforting, because it's stuff I understand. But, as you perfectly noted, it gets more complicated when doing projections, which is about the point in my research I donned a "huh?" face. –  Daniel Carvalho Jul 12 '12 at 19:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.