math

Algorithm to get aspect raio of a irregular shape

Im developing an image analysis app and need to calculate the aspect ratio of a segmented particle. According to http://www.sympatec.com/Science/Characterisation/05_ParticleShape.html the AR is given by (FIG 1) Xfmin/Xfmax. Any suggestion of an algorithm to get this values (Xf)? ...

C: enum VS #define for mathematical constants?

I'm wondering what would be the best way to store math constants that are used throughout an entire program? #define PI 3.14159265 #define SPEEDOFLIGHT 2.99792458e8 or enum constants { PI = 3.14159265; SPEEDOFLIGHT = 2.99792458e8; } Thanks ...

Why are 8 and 256 such important numbers in computer sciences?

I don't know very well about RAM and HDD architecture, or how electronics deals with chunks of memory, but this always triggered my curiosity: Why did we choose to stop at 8 bits for the smallest element in a computer value ? My question may look very dumb, because the answer are obvious, but I'm not very sure... Is it because 2^3 allo...

Photoshop PhotoFilter pixel Math

Has anyone used the photo filter in Photoshop? Edit > Adjustments > Photo Filter... It produces a really nice image tint that I've been unable to reproduce with blending modes. Has anyone got any idea of the pixel maths behind this filter? - So I can build a shader based on it. It seems to basically be a luminosity preserving colour ti...

How can I create a parallel polyline without self intersections?

The simple algorithm to create a parallel polyline to an existing polyline is simple: you can calculate the normal of each vertex (as the average of the segment's normals) and displace the vertices using the normal with whatever amount you want. However, there's a graphical problem when I try to use this algorithm on a curved polyline, ...

Neperian Logarithm on ActionScript 2???

How do i calculate the neperian logarithm on AS2 ??? ...

Calculate coordinates of a regular polygon's vertices

I am writing a program in which I need to draw polygons of an arbitrary number of sides, each one being translated by a given formula which changes dynamically. There is some rather interesting mathematics involved but I am stuck on this probelm. How can I calculate the coordinates of the vertices of a regular polygon (one in which all ...

evaluate whether a number is integer power of 4

The following function is claimed to evaluate whether a number is integer power of 4. I do not quite understand how it works? bool fn(unsigned int x) { if ( x == 0 ) return false; if ( x & (x - 1) ) return false; return x & 0x55555555; } ...

Explain the proof by Vinay Deolalikar that P != NP.

Recently there has been a paper floating around by Vinay Deolalikar at HP Labs which claims to have proved that P != NP. Could someone explain how this proof works for us less mathematically inclined people? ...

The new BigInteger

.NET 4.0 now has a new data type, System.Numeric.BigInteger. From what I understand, this can hold numbers that have, up to, 1 million digits. Simple arithmetic operations can be performed on this number. What I am wondering is how Microsoft implemented such a thing, given that it would obviously exceed 32-bits and even 64-bits. How does...

Why does adding two decimals in Javascript produce a wrong result?

Possible Duplicate: Is JavaScripts Math broken? Why does JS screw up this simple math? document.write(.1 + .2) // 0.3000000000000004 document.write(.3 + .6) // 0.8999999999999999 The first example is greater than the correct result, while the second is less. ???!! How do you fix this? Do you have to always convert decimal...

Determining whether point A needs to cut a corner to get to point B

I am looking for an efficient way to check if an object will cut a corner to get from point A to point B or prevent the object from moving from point A to point B if there is a diagonal unwalkable position in between. What is known: Every point is a square of width and height 1 Every point has a list of its 8 adjacent points A point c...

how to calculate the distance between two point on map ?

Possible Duplicates: help with GPS position calculate distance between 2 gps coordinates hi i have this (x,y) point: 40.716948,-74.006138 and i have this (x,y) point: 40.704977,-73.958588 (this points are on google map) how to calculate the distance between those points ? thank's in advance ...

How to calculate the angle of a vector from the vertical?

Hey, Im trying to find out the angle (in degrees) between two 2D vectors. I know I need to use trig but I'm not too good with it. This is what I'm trying to work out (the Y axis increases downward): I'm trying to use this code at the moment, but it's not working at all (calculates random angles for some reason): private float calcAng...

Limit camera pitch

How can I efficiently limit camera pitch when I have only camera quaternion? Do I have to convert to euler angles and then back to quaternion or is there any other way? ...

Does an algorithm exist to convert any number in the Aleph-Null set into the smallest possible computable number?

Possible Duplicate: Programming Logic: Finding the smallest equation to a large number. I'm looking for an algorithm that will take an arbitrary number from the Aleph-Null set (all positive integers)(likely to be absolutely enormous) and attempt to simplify it into a computable number (if the computable number takes up less sp...

What is the simplest way to get a ratio in PHP of multiple numbers?

I've adapted this from an example that I found on the 'net... function ratio($a, $b) { $_a = $a; $_b = $b; while ($_b != 0) { $remainder = $_a % $_b; $_a = $_b; $_b = $remainder; } $gcd = abs($_a); return ($a / $gcd) . ':' . ($b / $gcd); } echo ratio(9, 3); // 3:1 Now I want it...

C# - Windows Phone 7 SDK - math class

Hi It seems that I cant use system.math class within the windows phone projects... I cant even add the mscorelib.dll manually (windows phone dlls are different than windows dlls) Is there any way to use System.Math class within the windows phone SDK projects? Thanks. ...

number conversion general methodology ?

Hello experts, This is about how to do number conversion between binary to octal, octal to hexadecimal, binary to hexadecimal.. ( in all these decimal is no where there, either in source or destination ) Whenever decimal is involved either in source or destination i have a general methodology as, if decimal is source, do the mod oper...

How do I find the inverse tangent of a line?

Hey guys, I've got a line (x1,y1) and (x2,y2). I'd like to use tan inverse to find the angle of that line, how would I do so in java? I'd like to see what angle the line makes in relation to x1,y1 ...