[Q] Math & C++

Good Afternoon C++ Community!

First off, thank you all for your welcoming nature and helping me to expand my C++ knowledge.

However, I've run into a huge issue. Over Summer break, my teacher gave me some things that I could study to have a general understanding for our next class. Sadly, this has to do with Math, in High School I didn't think I would go to College, so I only took basic Algebra (11 years ago lol).

I was hoping that someone could kind of, point me in the right direction, in reference to this stuff? I know my teacher wants me to use SFML to do this, but I figured a general understanding on the methods of doing this in C++ would only help me. This is what he wanted me to look into:

Reflecting a Projectile Off a Wall at an Odd Angle (Dot Products)

Detect Whether Something is in your Field of View (Dot Products)

Fire a Projectile at any Angle (Like Geometry Wars, Sin/Cos/Tan)

Rotate a Point by some Angle, Around Another Point (Rotation Formula, Sin/Cos)

I apologize if I posted this in the wrong area, and I also apologize if this was wrong of me to ask in general. I really want to learn how to do this stuff, and I couldn't really find any examples online that I could understand. Thank you for taking the time to read this, and any help in figuring out how to do this, and maybe being pointed to a good resource for C++ Math Stuff, would be greatly treasured. Again, I am sorry for having to ask for this type of help.
closed account (48T7M4Gy)
.
Last edited on
You are asking some generalized questions; without more specifics I cannot comment more than guess.

Here are some good places to start with the math that I found online for you:

Trigonometry for Game Programming by Matthijs Hollemans
https://www.raywenderlich.com/35866/trigonometry-for-game-programming-part-1
https://www.raywenderlich.com/35944/trigonometry-for-game-programming-part-2
(These tutorials quickly get pretty heavy, but they have wonderful pictures explaining stuff. You can safely ignore all the stuff about Cocos2D.)

Also, Khan Academy has a pretty good video tutorial explaining right triangles and the Sine/Cosine/Tangent functions:
https://www.khanacademy.org/math/trigonometry/trigonometry-right-triangles/trig-ratios-similarity/v/similarity-to-define-sine-cosine-and-tangent
(Unfortunately, the author sometimes mumbles words, but you can follow the transcript below if it helps you.)

Linear Algebra for Game Developers at Wolfire.com
http://blog.wolfire.com/2009/07/linear-algebra-for-game-developers-part-1/
http://blog.wolfire.com/2009/07/linear-algebra-for-game-developers-part-2/
http://blog.wolfire.com/2009/07/linear-algebra-for-game-developers-part-3/
(Part 2 has the information about dot and cross products.)


Now, as for your specified concerns...

Make sure you understand the concepts of vectors and a coordinate system.
A vector can be treated as the far point of a right triangle in your coordinate system!

I'm not sure why you would need the dot product to reflect a projectile. You only need the angles of the wall's “normal” and the incident projectile.
The normal is a vector that is perpendicular to the wall (and one unit long).

Part 2 of the wolfire blog talks specifically about field of view and dot product.

Sine, cosine, and tangent are used to relate the unit components of a vector to the vector's angle against the coordinate +X unit vector.

To rotate stuff, you must first “translate” (or move) the thing you wish to rotate to the coordinate origin, perform your rotation, and then move it back to the original location.


I hope this helps get you started. I know there's a lot to wrap your head around, so be patient and take the time to study the math.

Let us know where you get stuck.
here some math examples for c++
http://cplusplus.happycodings.com/mathematics/
Ah man! Thank you guys so much for taking the time to help me out and answer my question! I'm going to look into this stuff as soon as I possibly can! This is what I love about this community, always down to help each other out >.<

I hope more people that might need resources like this, finds this thread. You guys are freaken life savers!
Topic archived. No new replies allowed.