math

Python: OverflowError: math range error

I get a Overflow error when i try this calculation, but i cant figure out why. 1-math.exp(-4*1000000*-0.0641515994108) ...

Traveling along the surface of a sphere using quaternions

I'm programming a 3D game where the user controls a first-person camera, and movement is constrained to the inside surface of a sphere. I've managed to constrain the movement, but I'm having trouble figuring out how to manage the camera orientation using quaternions. Ideally the camera up vector should point along the normal of the spher...

Find delta angle to use for rotation given entity with position, initial rotation and target point to 'face toward'

Hi, I'm coding a flocking algorithm in Java but I'm stuck at a certain point (using the Ardor3D libraries, in a 2D plane). Basically, I need to find the angle difference to add to the current rotation. If you can only get the way it should be pointing with polar coordinates with 0 degs at north and not the difference, not to worry -- I ...

Calculating angular rate.

Hi, I'm simulating a physical object, using a mass spring system. By means of deltas and cross products, I can easily calulate the up, forward and side vectors. I want to calculate what the angular rate (how fast it's spinning), for the object space X, Y and Z axis. Calculating the world space angle first won't help, since I need the a...

Collision algorithm for 2 moving object.

Hi, this is a Math problem for a 2d game. Given 2 object ( 2 car, 2 tank, 2...), for each object i know: 1. X, Y 2. Actual Speed 3. Degree of movement (or radiant) How to calculate the "effect" of a collision for the 2 object Ps: I "move" the object with this simple formula each tick of my "game loop": ychange = Math.Sin(radiant...

Verlet integration bouncing

I am trying to learn Verlet integration, mainly because I'm bored, and want to spice up my normal "bouncing ball" learning exercise. I have a simple bouncing ball Canvas/HTML5 page at http://sandbox.electricgrey.com:8080/physics/. If you click on it you'll notice that the ball doesn't always bounce back to the same height. Sometimes it ...

How to randomly but evenly distribute nodes on a plane

Hi All. I need to place 1 to 100 nodes (actually 25px dots) on a html5 canvas. I need to make them look randomly distributed so using some kind of grid is out. I also need to ensure these dots are not touching or overlapping. I would also like to not have big blank areas. Can someone tell me what this kind of algorithm is called? A re...

C# Mathematics Calculation not working properly

OK, so I'm performing an annoying math computation here, trying to solve for one of the cubic roots. Now, here is my C# code: public void CubeCalculate() { //Calculate discriminant double insideSquareRoot = (18 * cubicAValue * cubicBValue * cubicCValue * cubicDValue) + (-4 * (Math.Pow(cubicBValue, 3) * cubicDValue) + (Math.Pow...

Math notation font

Is there a font that can be used for math notation? I'm thinking there isn't. If that is the case, does anyone know what the simplest route is to having nice math notation in my iPad app? Update: Thank you for all the great responses. Looking at the current replies, would people generally recommend that if what I want to do is essenti...

Finding points on a rectangle at a given angle

I'm trying to draw a gradient in a rectangle object, with a given angle (Theta), where the ends of the gradient are touching the perimeter of the rectangle. I thought that using tangent would work, but I'm having trouble getting the kinks out. Is there an easy algorithm that I am just missing? End Result So, this is going to be a fu...

Math problem: how to blit correctly a "rotated" surface on another one

Hi, hope it's allowed to "crosspost" between stackexchange site... Does anyone know how to solve the following "math" problem ? http://gamedev.stackexchange.com/questions/5041/correct-blitting-2-surface-problem Thanks in advance ...

Best algorithm for comparing a base coordinate to a list of n coordinates and determining the closest m coordinates?

I have some code doing this right now. It works fine with small to medium sized lists, but when I have a list of size n > 5000 then the my algorithm can take almost 1 minute on a mobile device to run. I'm basically comparing a Coordinate object in Java to a list (Vector) of Coordinate objects. Here's my basic algorithm: traverse each ...