math

Elliptical rotation matrix?

In C++ we can rotate a point about an arbitrary axis: void radRotateAxis( float a, float b, float c, float theta ) { float newX = ( x*( a*a*(1-cos(theta)) + cos(theta) ) + y*( a*b*(1-cos(theta)) - c*sin(theta) ) + z*( a*c*(1-cos(theta)) + b*sin(theta) ) ); float newY = ( x*( a*b*(1-cos(theta)) + c...

How do I divide in the Linux console?

I have to variables and I want to find the value of one divided by the other. What commands should I use to do this? ...

Why can't decimal numbers be represented exactly in binary?

There have been several questions posted to SO about floating-point representation. For example, the decimal number 0.1 doesn't have an exact binary representation, so it's dangerous to use the == operator to compare it to another floating-point number. I understand the principles behind floating-point representation. What I don't under...

Motion planning without a graph across an infinite plane

An object is positioned at A and wants to move to B. I want to calculate a movement vector there that doesn't move within the distance D of the to-be-avoided points in array C. So if the move vector (B-A) normalized and multiplied with the objects speed would bring it within D of any point in C the vector is rotated so that it doesn't. ...

Building an activity chart combining two kinds of data

I'm building, for example, an application that monitors your health. Each day, you're jogging and doing push-ups and you enter the information on a web site. What I would like to do is building a chart combining the hours you jogged and the number of push-ups/sit-ups you did. Let's say on the first day, you jogged 1 hour and did 10 push...

Hardware Cache Formulas (Parameter)

The image below was scanned (poorly) from Computer Systems: A Programmer's Perspective. (I apologize to the publisher). This appears on page 489. I'm having a terribly difficult time understanding some of these calculations. At the current moment, what is troubling me is the calculation for M, which is supposed to be the number of uni...

How can I efficiently calculate the binomial cumulative distribution function?

Let's say that I know the probability of a "success" is P. I run the test N times, and I see S successes. The test is akin to tossing an unevenly weighted coin (perhaps heads is a success, tails is a failure). I want to know the approximate probability of seeing either S successes, or a number of successes less likely than S successes...

Why Base 2 with binary numbers?

History: I read from one of Knuth's algorithm book that first computers used the base of 10. Then, it switched to two's complement here. Question: Why does the base could not be -2 in at least a monoid? Examples: (-2)^1 = -2 (-2)^3 = -8 ...

What is the ideal growth rate for a dynamically allocated array?

C++ has std::vector and Java has ArrayList, and many other languages have their own form of dynamically allocated array. When a dynamic array runs out of space, it gets reallocated into a larger area and the old values are copied into the new array. A question central to the performance of such an array is how fast the array grows in siz...

Classifying english words into rare and common

Hi all, I'm trying to devise a method that will be able to classify a given number of english words into 2 sets - "rare" and "common" - the reference being to how much they are used in the language. The number of words I would like to classify is bounded - currently at around 10,000, and include everything from articles, to proper noun...

Are there any .NET Graphics Calculate Libraries?

Sorry for my bad English. I want to find a Calculate Library not a Drawing Library to help me do some graphics calulation like Bezier's length, point on Beziers or other metadata. Is there any library like this? ...

PHP Weight Algorithm

I'm wondering if this is a sufficient algorithm for finding the best value with a weighted system. Is there anything I could add to make it better? Edit: in this example I would like the probability of $object->get() returning test4 to be 4 times greater than the probability of it returning test1 (thanks acrosman) Thanks class weight...

SVG Linear Gradient Scale and Translation Question

I have the following radial gradient: <radialGradient inkscape:collect="always" xlink:href="#linearGradient2454" id="radialGradient2460" cx="4022.8572" cy="5451.2656" fx="4022.8572" fy="5451.2656" r="3559.865" gradientTransform="matrix(-0.1071067,-0.1166362,0.1377765,-7.0459663e-2,276.61943,1452.439)" gradi...

Finding the coordinates of tiles that are covered by a rectangle with x,y,w,h pixel coordinates

Say I have a tile based system using 16x16 pixels. How would you find out what tiles are covered by a rectangle defined by floating point pixel units? for eg, rect(x=16.0,y=16.0, w=1.0, h=1.0) -> tile(x=1, y=1, w=1, h=1) rect(x=16.0,y=16.0, w=16.0, h=16.0) -> tile(x=1, y=1, w=1, h=1) (still within same tile) rect(x=24.0,y=24.0, w=8....

WISE Windows Installer Editor Launch Condition Problem - Version Checking

I am working on a WISE Installer that needs to run on Java Version 1.5 or greater. So I have it read the registry for the Java Runtime Environment and get the "CurrentVersion" variable - for example 1.6, and place it in a WISE property. I am attempting to build a Launch Condition that prevents the Installer from continuing if it is run ...

C# function to find the delta of two numbers

I just wanted to know if there's anything built into the .net framework where I can easily return the delta between two numbers? I wrote code that does this but it sounds like something that should be in the framework already. Thanks. -Bryan ...

Is there an online archive for various math formulas?

What I'm looking for are archives of math formulas organized by topic or purpose etc. Basically an online library of math functions. For instance, I'm currently working on a project where I have a range from 0 to 2^32 and I need a formula to divide this range consecutively from 1 to n so that for each step, every 1 to n accounts for a c...

Swapping X,Y coordinates in a rectangle, what is this operation called?

Trying to find a good name for a method swapping each coordinate X and Y values. Is there a name for this operation? Essentially, here's what is done (1, 2) -> (2, 1) On a polygon, this is the same as having a rotation of -90 degrees and doing a horizontal flip or mirror. ...

Where can I learn the basics of game physics and the math behind it?

I taken math in college (trigonometry, calculus II...) but I don't know why you use tan, arctan, etc., in game physics. I know I can find working code and understand everything except why I am using a particular trig function, but I don't want that. I want to know why I am using arctan or sin. Where can I learn about why I am using th...

Is this game physics?

Related to my question here but not enough to open a new question. I wanted to make a good tower defense game and found this site. I saw math in it and made the mental leap that it was "game physics." Maybe it's not. I don't know. I was hoping someone could tell me. If it is not what kind of game programming is it? Just math you h...