Tag Info

Hot answers tagged

13

Not a book, but you should check out the math curriculum over at the Khan Academy. I'm in the process of using these videos to brush up on my own math skills. They cover an extremely broad range of material, and the author has been praised for his teaching style. IMO, truly an amazing resource. http://www.khanacademy.org/#Linear Algebra


12

speed = constant_factor / distance With constant_factor at 60, you get: 50->function->1.2 20->function->3.0 If you want to damp the curve a bit, add an exponentiation: speed = (constant_factor / distance) ^ (1 / damping_factor) With constant_factor at 80, and damping_factor at 2, you get: 50->function->1.26 20->function->2.0 ...


11

The point is between the 2 parallel lines if it's one side of one line and the other side of the other line (providing the lines point in the same direction). You can use the top answer from this question at stackoverflow to work out which side of a line (defined by 2 points on it) a point lies on. An alternative method would be to calculate the distance ...


10

Sergio you might want to aim more toward a Game Development math book like Essential Mathematics for Games and Interactive Applications, Second Edition: A Programmer's Guide Instead of the classical Linear Algebra you would learn in college. Also like Ron Warholic said, stating what your math comfort level is would better help us taylor a specific book.


10

Why choose? You can have both. (Without any added complexity to logic and without any additional memory requirement thanks to unions.) struct Mat4 { union { struct { float m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44; }; ...


10

Vector3 vT = v2 + headingNorm * 3; Be careful though, if v2 and v1 happen to be closer than 3 units away this will put you on the far side of v1. Maybe you want this to make the unit step back to make room for the attack. But then again be careful, because that means as you approach that attack point you will overshoot then correct and overshoot the ...


9

In openGl matrices are transposed in memory. So transpose the matrix is OK. But your code doesn't look correct. So you are in OpenGl. OpenGl uses right handed coordinate system. And for RH is lookat function defined like this: zaxis = normal(cameraPosition - cameraTarget) xaxis = normal(cross(cameraUpVector, zaxis)) yaxis = cross(zaxis, xaxis) xaxis.x ...


8

Linear Algebra is the foremost discipline for 3d graphics programming simply because it's the mathematical language for describing spatial geometry. Your other three topics are really just subsets of linear algebra: Vectors are a way of thinking about points in space Matrices are ways of thinking about transformations of space and objects: translating ...


6

To get a smooth random walk, you could use Catmull-Rom splines. This kind of spline takes a sequence of points and generates smooth curves that pass through each point. So, you could generate random waypoints for the sprite to move through and animate it along a Catmull-Rom spline through the waypoints. For the spline to work you'll need a total of four ...


6

I use the following method which is pretty much just an implementation of this algorithm. It's in C# but translating it to ActionScript should be trivial. bool IsIntersecting(Point a, Point b, Point c, Point d) { float denominator = ((b.X - a.X) * (d.Y - c.Y)) - ((b.Y - a.Y) * (d.X - c.X)); float numerator1 = ((a.Y - c.Y) * (d.X - c.X)) - ((a.X - ...


6

Mathematically, the quantity you're asking about is called the operator norm. Unfortunately, there's no simple formula for it. If it's a fully general affine transformation - for instance, if it could have an arbitrary combination of rotations and nonuniform scales, in any order - then I'm afraid there's nothing for it but to use singular value ...


5

P = t * (B-A) + A Px = t * (Bx-Ax) + Ax Py = t * (By-Ay) + Ay Px - Ax Py - Ay ------- = ------- (Bx-Ax) (By-Ay) (By - Ay) Py = (Px - Ax) * --------- + Ay (Bx - Ax) (5 - -1) 6 Py = (Px - 2) * -------- + -1 = (Px -2) * --- - 1 (4 - 2) ...


5

You can do that with different approaches; segment vs segment using parametric lines plus some verifications (because lines are not segments). segment vs box segment vs circle (this one would be my favorite) . But as you request for a segment vs segment intersection test, here is a pseudo C++ example extracted from the very interesting book "Real time ...


4

Instead of beziers, you probably want b-splines or catmull-rom splines. float bspline(float t, float p0, float p1, float p2, float p3) { float it = 1.0f - t; float b0 = it*it*it * (1.0f / 6.0f); float b1 = (3*t*t*t - 6*t*t +4) * (1.0f / 6.0f); float b2 = (-3*t*t*t +3*t*t + 3*t + 1) * (1.0f / 6.0f); float b3 = t*t*t * (1.0f / 6.0f); return ...


4

For your first question, about vRayOrig & vRayDir, you should use what you need to use -- certainly the plane and the ray must be defined in the same space, or the results you get out of the intersection test will be meaningless. So you need to either define or transform the plane into the same space as the ray, or the other way around. For the second ...


4

Although someone has already provided an answer deemed satisfactory, I'm unsure the method you described will yield an accurate time of impact (TOI). My first inclination is that to find an exact answer to the question, "how far can the player move before colliding with a part of the cave, if a collision occurs at all?" requires resorting to continuous ...


4

represent the distance you travel as a number between 0 and 1. The problem with your code is that you don't have any notion of "how far am I between the two endpoints." function lerp(start, dest, dist) { var x = start.x * (1 - dist) + dest.x * dist; var y = start.y * (1 - dist) + dest.y * dist; return [x,y]; } lerp(start, dest, 0) -> start ...


4

Assuming you've benchmarked this and are sure this is a bottleneck keep reading. If not stop. Don't worry and be happy :). It's true that you will need to run the collision check algorithm every time you fire a bullet. And depending on how long it takes the bullet/laser to disappear you will have to do it multiple frames. However when you implement a solid ...


4

GLM's rotation function uses Euler's rotation theorem, which implies that any rotation or sequence of rotations of a rigid body in a three-dimensional space is equivalent to a pure rotation about a single fixed axis. However consecutive calls to GLMs rotate function just multiply the rotation so rotating a rigid body by Yaw, Pitch, Roll is as simple as ...


4

you can concatinate 3 matrices first a translation to put 1,1 at 0,0, then the rotation and then translate 0,0 back to 1,1 if you use affine transformation matrices this is easy [1,0,-1][0,1,-1][0,0,1] * rotationMatrix * [1,0,1][0,1,1][0,0,1] if you don't use affine transformations then just subtract 1,1 on each point then rotate around 0,0, then re-add ...


4

Why are all three lines of the formula seperated by commas? P(x,y,t) is a vector valued function. Its values are thus 3D vectors. The commas just separate these components, probably akin to a Matlab style of coding. D refers to a directional vector (i think) D is a 2D vector in the (x,y) plane. It describes the direction (and magnitude, if not ...


3

Here are my recommendations: Data structures for game programming LINK Excellent book for a thorough but easy to understand breakdown of all the useful data structures that games use. What's more, the author provides samples that come in the form of mini-games or interactive demos. Absolutely must have book for beginners. Essential Mathematics for Games ...


3

If talking about gravity, you could consider the gravity equation.. from wikipedia: where: F is the force between the masses, G is the gravitational constant, m1 is the first mass, m2 is the second mass, and r is the distance between the masses. http://en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation


3

http://www.cs.virginia.edu/~gfx/Courses/2003/ImageSynthesis/papers/Acceleration/Fast%20MinimumStorage%20RayTriangle%20Intersection.pdf This paper provides (apparently) the most computationally efficient means of calculating ray-triangle intersection. Not sure if it directly addresses the question but thought it may be useful here.


3

Here is an algorithm for intersection only (doesn't cover touching) that I believe is fast. if t0, t1 and t2 are all on the same side of line P0P1, return NOT INTERSECTING if P0 AND P1 are on the other side of line t0t1 as t2, return NOT INTERSECTING if P0 AND P1 are on the other side of line t1t2 as t0, return NOT INTERSECTING if P0 AND P1 are on the ...


3

The dot method you have on the pastebin is fine if all objects are on the same plane and it is essentially a 2d problem (regardless of if the game is 2d or 3d). If, however, you are in a 3d environment where you need to adjust cannon yaw & pitch, then the cross method would be better because it would give both the direction to turn(rotate towards target) ...


3

I would take the "wander" steering-behavior (source code can be found here) and tweak it in a way so that the random numbers are biased towards your target.


3

IIRC: (might have mixed up left & right but that shouldn't matter) Line segment 1 is A to B Line segment 2 is C to D A line is a never ending line, the line segment is a defined part of that line. Check if the two bounding boxes intersect : if no intersection -> No Cross! (calculation done, return false) Check if line seg 1 straddles line seg 2 and ...


3

This answer still ignores the attempt to use matrix rotation, but I realized that there was a simple yet general solution. First, assuming that the shape is encoded as coordinates of blocks in a grid, you have an arbitrary shape containing blocks with coordinates in the X and Y axes from 0 to n, where n+1 is the maximum size of a block (traditional Tetris ...


3

Your example is stuffed with bugs and inconsistencies, it is really hard to read, but your understanding error seems to be in sentence 4: add the origin coordinates back to each resulting coordinate That is not the original coordinates, but the coordinates of the origin that you are rotating around, so (1, 2) in the example case. By the way, should ...



Only top voted, non community-wiki answers of a minimum length are eligible