|
Glaiel-Gamer
|
 |
« Reply #1455 on: January 20, 2011, 10:52:03 AM » |
|
The amount of uses I've found for dot-prod over the years is amazing.
Mostly just from wanting to know if two lines are pointing the same direction.
What's wrong with atan2(x1 - x2,y1 - y2)? the jump from -180 to 180
|
|
|
|
|
Logged
|
|
|
|
|
Fallsburg
|
 |
« Reply #1456 on: January 20, 2011, 12:18:21 PM » |
|
The amount of uses I've found for dot-prod over the years is amazing.
Mostly just from wanting to know if two lines are pointing the same direction.
What's wrong with atan2(x1 - x2,y1 - y2)? the jump from -180 to 180 This. Well, that and the fact that atan2 is always y then x.
|
|
|
|
|
Logged
|
|
|
|
|
|
|
bateleur
|
 |
« Reply #1458 on: January 21, 2011, 12:00:18 AM » |
|
Nice concept, but the line length limit is super annoying. 
|
|
|
|
|
Logged
|
|
|
|
|
st33d
Guest
|
 |
« Reply #1459 on: January 21, 2011, 12:43:06 AM » |
|
Yea, made early in my game making career. AS2 and an inexperienced programmer. 
|
|
|
|
|
Logged
|
|
|
|
|
bateleur
|
 |
« Reply #1460 on: January 21, 2011, 01:16:15 AM » |
|
AS2  <- flashbacks!
|
|
|
|
|
Logged
|
|
|
|
|
Skomakar'n
|
 |
« Reply #1461 on: January 21, 2011, 03:38:46 AM » |
|
The amount of uses I've found for dot-prod over the years is amazing.
Mostly just from wanting to know if two lines are pointing the same direction.
What's wrong with atan2(x1 - x2,y1 - y2)? the jump from -180 to 180 This. Well, that and the fact that atan2 is always y then x. That can't be too hard to convert...
|
|
|
|
|
Logged
|
|
|
|
|
Fallsburg
|
 |
« Reply #1462 on: January 21, 2011, 10:14:18 AM » |
|
That can't be too hard to convert...
The y then x? Or the 180 -180 jump? I agree that it isn't too hard to convert, but the bigger question is "Why bother?" If one way requires extra work and one way doesn't, why wouldn't you go with the easier way (assuming that it is comparable in terms of computation or memory limits [whichever is more important])?
|
|
|
|
|
Logged
|
|
|
|
|
Glaiel-Gamer
|
 |
« Reply #1463 on: January 21, 2011, 10:22:27 AM » |
|
That can't be too hard to convert...
The y then x? Or the 180 -180 jump? I agree that it isn't too hard to convert, but the bigger question is "Why bother?" If one way requires extra work and one way doesn't, why wouldn't you go with the easier way (assuming that it is comparable in terms of computation or memory limits [whichever is more important])? which angle is closer to 130, 20 or -160?
|
|
|
|
|
Logged
|
|
|
|
|
BorisTheBrave
|
 |
« Reply #1464 on: January 21, 2011, 12:38:33 PM » |
|
That can't be too hard to convert...
Seriously, quit while you are ahead, and don't argue this. This isn't some matter of taste thing, vectors are just superior in 2d, and impossible to avoid in 3d (along with their bigger cousins, matrices and quaterions, which are equally vital). - Vastly faster
- DRY - Don't you find it tedious writing virtually identical lines of code for x and y
- Dot product and cross product replace virtually all geometry calculations with easier ones
- No discontinities, double values (-180,180)
- Natural - unlike angles you never worry about degrees vs radians, clockwise vs counterclockwise or what direction 0 is.
- It allows directions, positions, and offsets to be manipulated by one framework.
- Much mathematics on the reals carries over to vectors easily - Polynomials you learnt at school trivially become bezier splines. And vector notation means you can solve geometry problems without a diagram.
- Works the same(ish) for 2d and 3d
That is not to say you can do everything with them (e.g. constant angular rotation with variable timestep), just that you should work in vectors, and convert when necessary, not the other way around.
|
|
|
|
|
Logged
|
|
|
|
|
Glaiel-Gamer
|
 |
« Reply #1465 on: January 21, 2011, 12:55:07 PM » |
|
vectors are also easily orientation-independent (useful for controls if your camera rotates)
|
|
|
|
|
Logged
|
|
|
|
|
Evan Balster
|
 |
« Reply #1466 on: January 21, 2011, 02:19:12 PM » |
|
Quaternions. <3 Something else I think kicks matrix ass. (for the purpose of game logic programming--again, who wants to do expensive matrix ops twenty times per frame to calculate character physics?)
One confession, though: My vector class is still named Point, and I don't have the heart to change it because "Vector" is a longer name, though I do have a typedef. (I adhere rather strictly to 81-column lines in my code)
|
|
|
|
|
Logged
|
|
|
|
|
Glaiel-Gamer
|
 |
« Reply #1467 on: January 21, 2011, 02:37:02 PM » |
|
Quaternions. <3 Something else I think kicks matrix ass. (for the purpose of game logic programming--again, who wants to do expensive matrix ops twenty times per frame to calculate character physics?)
One confession, though: My vector class is still named Point, and I don't have the heart to change it because "Vector" is a longer name, though I do have a typedef. (I adhere rather strictly to 81-column lines in my code)
Vec2D/Vec3D is a shorter name
|
|
|
|
|
Logged
|
|
|
|
|
Pirate Hearts
|
 |
« Reply #1468 on: January 21, 2011, 02:47:29 PM » |
|
Quaternions are pretty awesome, though I'll admit I've never really been able to wrap my mind around how they work and why they do what they do. I just like 'em because they're more convenient and efficient than rotation matrices in many cases.
|
|
|
|
|
Logged
|
|
|
|
|
Riley Adams
|
 |
« Reply #1469 on: January 22, 2011, 02:00:25 AM » |
|
Yay, got my network wrapping stuff mostly working (endians and all!).
|
|
|
|
|
Logged
|
|
|
|
|