math

Calculating RMS with overlapping windows

I have a 1-dimensional float array of root mean square values, each calculated with the same window length. Let's say RMS = {0, 0.01, 0.4, ... } Now the RMS for a larger window, which can be represented as a range of the original windows, can be calculated as the RMS of the "participating" RMS values from RMS[i] to RMS[i + len]. Here ...

What's the most efficient way to detect triangle-triangle intersections ?

How can I tell whether two triangles intersect in 2D Euclidean space? (i.e. classic 2D geometry) given the (X,Y) coordinates of each vertex in each triangle. ...

What type of Math should I study to prepare for game programming?

Next year I will be starting a degree in game programming. I have been told to brush up on my math. Which chapters of math text books should I read over? The course is described as: The Qantm Bachelor of Interactive Entertainment (with a Major in Games Programming) focuses on specific areas which are critical to developing kno...

How do you animate a display object in an arc in AS3?

This is for a game in a flash AS3 only project. the player controls a character with a gun. By clicking on the screen the gun fires a missile in an arc to the point clicked. Whats the best way to calculate the x and y co-ordinates of the missile for each frame? ...

Convergence of Mathematics and Programming Languages

It seems that there is a strong movement for the convergence of mathematics and computer programming languages, this is notably evidenced by the influence of the lambda calculus on modern languages. Most of the time I do not think with mathematics, I think with logic. It seems to me that many of the phenomenon that can be modeled mathema...

Adjust items chance to be selected from a list

I have a list of items. When I create the list each item has equal chance to be selected. But as an item is selected its chance goes down while the others chance goes up. If a new item is added during the process, it should have the highest chance to be selected with its chances falling off as it is selected. I am looking for a good ...

What is negative squared euclidean distance?

It is described as -||xi-xy||^2. So for 2 two dimensional points do I code it like this? - ((x1-x2) + (y1-y2))^2 or -( (x1-x2)^2 + (y1-y2)^2 ) or -(sqrt( (x1-x2)^2 + (y1-y2)^2 )) or some other way? ...

Calculate 3D vector perpendicular to a plane generated by two vectors

I am new to dealing with 3D, and even simple stuff makes my head spin around. Sorry for the newbie question. Lets say I have 2 vectors: a(2,5,1) b(1,-1,3) These vectors "generate" a plane. How can I get a third vector perpendicular to both a and b? I can do this in 2D using a vector c(A,B) and turning it into c'(-B,A). Thanks for t...

StackOverflow's Popularity algorithm in MySQL

How would you write SO's Popularity algorithm in MySQL? The algorithm is detailed here: http://stackoverflow.com/questions/32397/popularity-algorithm. thanks! ...

What is the best way to rotate a CGPoint on a grid?

I want to rotate a CGPoint on the screen depending on the angle and the rotation is anchored on another point. Was wondering what is the most efficient way of doing this? ...

When I divide numbers in clojure i get a fraction , how do I get the decimal?

When i do (/ 411 125) , i dont get it in terms of decimal, how do I do that? ...

Algorithm for Finding Good, Reliable Players

I've the following players, each value corresponds to a result in percentage of right answers in a given game. $players = array ( 'A' => array(0, 0, 0, 0), 'B' => array(50, 50, 0, 0), 'C' => array(50, 50, 50, 50), 'D' => array(75, 90, 100, 25), 'E' => array(50, 50, 50, 50), 'F' => array(100, 100, 0, 0), 'G' =...

Need someone to verify that my math is correct

I've been sitting with a pencil for the better part of the evening trying to recall how to implement a scalable viewport that can navigate a 2D area. It's been a while since I've first heard of it, but I think I've figured it out, I just need to verify. We have a 2D world with a "classic" cartesian coordinate system, x-axis points to th...

Solving X from linear equations in Scheme?

I want to solve x. How can I do it in Scheme? T1-F2=0 F1+T2=GM-Gm Cos(60)(2.5*Gm+x*GM-l*F1)-l*Sin(60)*T1=0 F1=0.1*T1 F2=0.3*T2 M=20 m=80 l=5 My try is: (lambda T1 . ;; T1=F2 (lambda F2 . ;; F2=0.3*T2 (lambda F1 . ;; F1=0.1*T1 (lambda Gm . ( lambda GM . (- ( * 1/2 ( - ...

online math/latex editor/engine?

Hi all, I was just wondering whether there are any good open source online math editor? I couldn't find anything searching on google. Thanks a lot! ...

Shortest distance between points algorithm

Given a set of points on a plane, find the shortest line segment formed by any two of these points. How can I do that? The trivial way is obviously to calculate each distance, but I need another algorithm to compare. ...

cosf(M_PI_2) not returning zero

This started suddenly today morning. Original lines were this float angle = (x+90)*(M_PI/180.0); float xx = cosf(angle); float yy = sinf(angle); After putting a breakpoint and hovering cursor.. I get the correct answer for yy as 1. but xx is NOT zero. I tried with cosf(M_PI_2); still no luck.. it was working fine till yesterday.. I ...

Vertex shader world transform, why do we use 4 dimensional vectors?

From this site: http://www.toymaker.info/Games/html/vertex%5Fshaders.html We have the following code snippet: // transformations provided by the app, constant Uniform data float4x4 matWorldViewProj: WORLDVIEWPROJECTION; // the format of our vertex data struct VS_OUTPUT { float4 Pos : POSITION; }; // Simple Vertex Shader - carry ou...

Why does stdlib.h's abs() family of functions return a signed value?

The negative implication of this is noted in the man page: NOTES Trying to take the absolute value of the most negative integer is not defined. What's the reasoning behind this and what's the best recourse for a person who would like to avoid undefined behavior? Do I have to resort to something like: unsigned...

What is the expected period of a repeating event that has a random (but limited) interval between each occurrence?

Okay, so we've got this event. Awesome, right? We've also got a timer with a fixed maximum duration, like one of those rotary kitchen timers. Not exactly awesome, but definitely handy. When the timer goes off, the event occurs, and the timer is reset to some random value between zero and the maximum duration (every value has an equal c...