math

Where to start learning math for game programming for a math newbie?

I'm not new to programming, but I am new to game programming. It was always my dream to create games, and since I'm 21 today, I think better start now than later. In the past I had no problems with math, but I did have the constant feeling that I could solve the problems but not understand what was happening. "Why am I doing this and w...

JavaScript - Incorrect division

newPercent = 15/30; //result=Math.round(newPercent*100)/100 //returns 28.45 $('#counter').text(newPercent); $('#howMany').text(count); returns back 0.5% which is suppose to be 50.00%... how do I fix this? :S ...

Help with symplectic integrators

I'm trying to develop a physics simulation and I want to implement a fourth-order symplectic integration method. The problem is that I must be getting the math wrong, since my simulation is not working at all when using the symplectic integrator (as compared to a fourth-order Runge-Kutta integrator that works reasonably well for the simu...

Formula calculation mechanism for web

There is a group of simple formulas for calculating some values. I need to implement this for the web interface (I make this in PHP). To store formulas I am using simple format like this: "X1+X2+X3". When I need to make calculations, I call function preg_replace in the loop for replacing X1, X2 .. by real data (entered by user or saved...

How Can I Mix Math with Regex's in Awk or Sed?

Hi All, I've used regex's in sed before and used a bit of awk, but am unsure of the exact syntax I need here... I want to do something like: sed -i 's/restartfreq\([\s]\)*\([0-9]\)*/restartfreq\1$((\2/2))/2/g' \ my_file.conf where the second match is divided by 2 and then put back in the inline edit. I've read though that sed ca...

Advice a book and/or web ressource on Reed-Solomon error correction

Hi, I'd like advice on a book or web resource, that comprehensively teaches me Reed-Solomon error correction. I found some web resources and some university PDF's, but none of them was able to really teach me how to compute it (and error correct afterwards). I'd prefer a book on it if possible. For clarification: I'm not looking for a...

interpretation problem I dont know what to do?

Hello I dont understand what I supposed to do in this exercise, I am begining programming constest, if you can help me is very appreciated, I have seen formulas, but I dont understand what to do, I feel very stupid , and for everyone is easy :( http://www.codeforces.com/contest/1/problem/A ...

PHP 64 bit numbers?

Hello, I have a simple function that I'm using but for some reason the number doesn't calculate correctly as it would in a calculator. I think it has something to do with the numbers being too large, or something to do with 64 bit. Is there any way I can convert them so that they would work correctly? $sSteamComID = 76561197990369545...

How can I model this usage scenario?

I want to create a fairly simple mathematical model that describes usage patterns and performance trade-offs in a system. The system behaves as follows: clients periodically issue multi-cast packets to a network of hosts any host that receives the packet, responds with a unicast answer directly the initiating host caches the responses...

Probability book or video for purely analytical brain

That's it. I suck at probability theory. I simply don't seem to get it. The thing is, I have strongly analytical brain, but every single book that I ran to, taught probability using synthesis and not analysis. Since probability theory is crucial for every programmer and I want to improve, could you tell me the book or video lecture that...

How to implement a random float function so that it does not lose entropy? (PHP)

Hi, I am trying to generate random floats using nothing but bytes I get from /dev/urandom. Currently my best idea is to get the platform precision doing something like: $maximumPrecision = strlen('' . 1/3) - 2; and then construct a string of 0-9 in a loop the number of times $maximumPrecision tells us. For examle, if the precision is...

Drawing lat/lng points on an image

I have the following: An image - a hand drawn map - of an area of roughly 600x400 meters. The image is drawn on top of Google Maps tiles. The latitude/longitude (from Google Maps) of the corners of this image. Or put differently, I have the north and south latitude and the east and west longitude of the image. A latitude/longitude coor...

Calcuate x/y point that 2 moving balls will collide

Im trying to make what is (essentially) a simple pool game, and would like to be able to predict where a shot will go once it hits another ball. The first part is, I believe, to calculate if the cueball will hit anything, and if it does, where it collides. I can work out collision points for a line and a ball, but not 2 balls. So given...

Calculating distance between two points, using latitude longitude, what am I doing wrong?

I'm trying to solve this assignment and it's taking too much time: Here's my try, it's just a snippet of my code: final double RADIUS = 6371.01; double temp = Math.cos(Math.toRadians(latA)) * Math.cos(Math.toRadians(latB)) * Math.cos(Math.toRadians((latB) - (latA))) + Math.sin(Math.toRadians(latA)) ...

What is use of compound ratio?

What is use of compound ratio? ...

Simple Math Issue in C#

So i have this program that takes 3 scores out of a possible 200 each then is supposed to get the average and display the percentage. but when i input numbers i get 00.0 as an answer. What could i be doing wrong? using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { c...

Determining an Arbitrary Range of Digits in a Target Base from a Sequence and Source Base

If I have a function f that computes element m of a sequence of digits in base b, is it in general possible to write a function g that computes element n of the corresponding sequence in base c ? As a contrived example, say f produces binary and g produces hexadecimal: f(m) 1, 0, 1, 0, 1, 0, 1, 0, ... g(n) A, A, ... Now say f is i...

Write a function to solve a simple linear equation

I need to know how to write a function to solve a simple linear equation like 2x +1 = 5. How would one do this? If anyone can show some code or point me to a site, it would be much appreciated. ...

Computing an angle from x,y coordinates

I'm trying to do collision testing between a finite line segment, and an arc segment. I have a collision test which does line segment vs. line segment, so I was going to approximate these arc segments with line segments and run my existing test. The data I have defining the arc segment(s) are three points. Two of which are endpoints th...

Is there an algorithm for solving such projection reconstruction geometric problem?

We have a grid with red squares on it. Meaning we have an array of 3 squares (with angles == 90 deg) which as we know have same size, lying on the same plane and with same rotation relative to the plane they are lying on, and are not situated on same line on plane. We have a projection of the space which contains the plane with squares...