Processing has a great function I use all the time:
map(value, low1, high1, low2, high2)
http://processing.org/reference/map_.html
It remaps value (that has an expected range of low1 to high1) into a target range of low2 to high2).
I want to understand the math behind it so I can use it in other languages.
Anyone want to throw me a ...
I have to solve polynomial equation system which gives error as it has infinite solutions and i just require few solutions(any 2 or 3) so how can i get them? , Can i specify condition on solution like solutions whose values range between 1 to 10 so that i can get few value.
Equations are actually long complicated but infinite solutions ...
Possible Duplicate:
John Carmacks Unusual Fast Inverse Square Root (Quake III)
I came across this piece of code a blog recently - it is from the Quake3 Engine. It is meant to calculate the inverse square root fast using the Newton-Rhapson method.
float InvSqrt (float x){
float xhalf = 0.5f*x;
int i = *(int*)&x;
i ...
I was wondering if there was any tutorial that introduces 3D Graphics theory while showing relevant code, without using OpenGL or DirectX or something. I'm very comfortable with engineering math (I'm an A/V DSP student, so I work with a lot of math all the time).
Most of the tutorials I see either show me the same old matrix translatio...
Hello,
The problem I have has got me puzzled. The problem is explained below,
There is a container, for example lets say which has a volume of "V". The container needs to be filled with various types of boxes, where each type has a unique size (volume), for example lets say
Box Type A - has a volume of K
Box Type B - has a volume of L...
I'm trying to calculate the coefficient of determination (R^2) in Python, but I'm getting a negative value in certain cases. Is this a sign that there's an error in my calculation? I thought R^2 should be bounded between 0 and 1.
Here's my Python code for doing the calculation, adapted straight from the WP article:
>>> yi_list = [1, 1,...
I am calculating a formula and would like to know how to write exp(a/b) in C#.
I heard about math.exp, but it takes only one parameter.
...
I am capturing some points on an X, Y plane to represent some values. I ask the user to select a few points and I want the system to then generate a curve following the trend that the user creates. How do I calculate this? So say it is this:
Y = dollar amount
X = unit count
user input: (2500, 200), (4500, 500), (9500, 1000)
Is there a...
Hey guys,
I've got a line (x1,y1) and (x2, y2). I'd like to see if point (x3, y3) lies to the "left" or "right" of said line. How would I do so?
...
Hi,
I've been learning Ruby, so I thought I'd try my hand at some of the project Euler puzzles. Embarrassingly, I only made it to problem 4...
Problem 4 goes as follows:
A palindromic number reads the same
both ways. The largest palindrome made
from the product of two 2-digit
numbers is 9009 = 91 × 99.
Find the largest p...
Hello,
I would like to create a function floor(number, step), which acts like :
floor(0, 1) = 0
floor(1, 1) = 1
floor(1, 2) = 0
floor(5, 2) = 4
floor(.8, .25) = .75
What is the better way to do something like that ?
Thanks.
...
I work in GIS with VBA. I have a geometric network that contains 2 layer River (polyline) and Hydrometry station (Point). I want to find the closest Point to the selected River, but I want that distance to be measured on the network, not the direct distance.
How can I code this in VBA?
...
And can you give me an example of an algorithm?
EDIT: And then how would I calculate the math using Javascript? Can someone add that? Sorry to not include that context originally..
NOTE: I am using 'flot' to graph it and the input for flot is a javascript array like this:
[[x,y],[x,y],[x,y]...]
So given the values that change the cu...
My Code:
-(void)ShootingWithJoystick {
if (_nextProjectile != nil) return;
CGPoint location = CGPointMake(rightJoystick.velocity.x,rightJoystick.velocity.y);
// Set up initial location of projectile
_nextProjectile = [[CCSprite spriteWithFile:@"player.png"] retain];
_nextProjectile.scale = 0.2f;
...
How can a find if a point lies within a 2D rectangle given 4 points?
...
Hi I am trying to create a simple pie chart using the HTML canvas element.
I found a nice tutorial on the web and starting to learn how it is done.
Now I want to add some text and since I am pretty retarded at math/geometry I need to know how to find the center of each slice in the pie where the text can be added.
Here is the loop code...
Question pertains to series type math problems:
x^1+x^2+x^3+...+x^n
please note, this is just a simple example. each iteration of n could be more complex. i am not actually looking to calculate this equation.. just curious about what constructs are available..
i know i could write a simple loop or use recursion to accomplish this. Bu...
Suppose I want to randomly select a number n between 0 and 30, where the distribution is arbitrary, and not uniform. Each number has a corresponding weight P(n): P(0) = 5, P(1) = 1, P(2) = 30, P(3) = 25, and so on and so forth. How do I do a random selection from this set, such that the probability of selecting a number is proportional t...
I've been able to solve the following problem using std::next_permutation (c++) etc,
but I'm now thinking about it in a more general and would very much like to form an
expression as this type of problem seems to lend itself - though I'm not having any luck as of yet.
Here is the question:
Given a running race with N contestants, wha...
Hi all, im making a drop down menu in flash and i want it to slide down. At the moment im using a linear slide ( _y += 5, _y -= 5) etc.
I know there are other types of transitions like exponential and the like, how would i go about implementing them? I also remember there was a website once that showed all sorts of slide animations in ...