Tag Info

Hot answers tagged

22

Yes, To name a few: Pannini Mercator Fisheye Miller The Pannini projection, for example, can capture wide fields of view in nice ways. (totally just my opinion) I think implementation details would be beyond the scope of this specific question. EDIT: Thanks for the comment, I did misspell Pannini. And to make this edit worthwhile here are a few more: ...


14

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


14

It depends on what you mean by "that could be used in a 3D system such as OpenGL". :) Narrowly speaking, 3D graphics hardware and APIs like OpenGL only deal correctly with linear projections - projections that map straight lines in world space to straight lines on the image. They never distort something into a curved shape (unless it was curved to begin ...


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

You'll need to duplicate the normal for the corner N times (where N is the number of "sides" it is shared amongst). If you try to use one value for all "sides," you'll end up averaging it, and your lighting will not appear to have that hard edge that you're looking for.


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


9

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


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


7

Calculate a vector from B to A, normalize it (divide by the vector's length), then multiply by the circle size: vx = A.x - B.x vy = A.y - B.y length = sqrt(vx*vx + vy*vy) C.x = vx / length * size + A.x C.y = vy / length * size + A.y For the angle you can use the atan2 function, if your language has it.


6

This is by far the best ball to ball collision detection article I have come across. Pool Hall Lessons: Fast, Accurate Collision Detection Between Circles or Spheres


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

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


6

A 2D vector has two values (x and y), and it basically says how far you go from the point of origin in the x- and in the y-direction. For example, a vector of (3,4) goes 3 units in x direction and 4 units in the y direction, resulting in an angled line with a length of 5 (3² + 4² = 9+16 = 25, root of that is 5). So the vector basically gives you two pieces ...


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


5

Looks like V = p1 - p0. Since then t = 0 when p2 = p0, and t = 1 when p2 = p1.


5

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


5

You have incorrectly implemented the formula as a function. The function is missing + 1 after the call to Math.sin(), which moves the wave to the range [0, 2]. Regarding your second problem, I don't see anything wrong. In fact the screenshot looks exactly like it should and seems to match the plotted curve. Try with k=10 and you should see the difference ...


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

Here's a great intro http://blog.wolfire.com/2009/07/linear-algebra-for-game-developers-part-2/


4

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


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



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