math

How to get around some rounding errors?

I have a method that deals with some geographic coordinates in .NET, and I have a struct that stores a coordinate pair such that if 256 is passed in for one of the coordinates, it becomes 0. However, in one particular instance a value of approximately 255.99999998 is calculated, and thus stored in the struct. When it's printed in ToStrin...

How to detect and remove guide lines from a scanned image/document efficiently ?

Hello All For my project i am writing an image pre processing library for scanned documents. As of now I am stuck with line removal feature. Problem Description: A sample scanned form: Name* : ______________________________ Age* : ______________________________ Email-ID: |_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_| Note: Following are the f...

Calculating complex numbers with rational exponents

Yesterday I created this piece of code that could calculate z^n, where z is a complex number and n is any positive integer. --snip-- float real = 0; float imag = 0; // d is the power the number is raised to [(x + yi)^d] for (int n = 0; n <= d; n++) { if (n == 0) { real += pow(a, d); } else { // binomial theorem switch...

Maths question about point rotation in .Net

I have a partial answer. Starting with: newHeight = Height * cos(radians) + Width * sin(radians) newWidth = Height * sin(radians) + Width * cos(radians) I can reverse the equations to get: temp = sqr(cos(radians)) - sqr(sin(radians)) Height = newHeight * cos(radians) - newWidth * sin(radians) / temp Width = newWidth * cos(radians)...

How to convert ZXZ rotation matrix to Euler angles?

I'm using Catia software. When I query the position of an object inside my CAD drawing, the system returns a 3x4 matrix [Rotations | Translations] I think that the Rotations are expressed in a ZXZ fashion but for further processing I'd like to convert that rotation matrix to a XYZ notation, is this something doable? Edit: My object ...

How to compute the modulus of a float in TSQL?

The modulus function in Microsoft SQL Server only works on certain data types. According to the MSDN Article [1] on the modulus operator, you normally would use modulus like this... dividend % divisor dividend Is the numeric expression to divide. dividend must be a valid expression of any one of the data types in the integer and mon...

Dividing a plane of points into two equal halves

Given a 2 dimensional plane in which there are n points. I need to generate the equation of a line that divides the plane such that there are n/2 points on one side and n/2 points on the other. (by the way this not home work, I am just trying to solve the problem) ...

Math algorithm/function to convert this number to 40?

I’m programming a knob that has an arrow the position of which is defined from an arc number. I’m looking to find a way to convert this arc number to a number that will represent a temperature. The minimum the arc number will be is 1.3 and the maximum will be 1.7. 1.3 needs to equal 40 and 1.7 needs to equal 99. Is this possible? ...

How to calculate Mahalanobis distance between two time series of equal dimensions?

I am doing some data-mining on time series data. I need to calculate the distance or similarity between two series of equal dimensions. I was suggested to use Euclidean distance, Cos Similarity or Mahalanobis distance. The first two didn't give any useful information. I cannot seem to understand the various tutorials on the web. So, Gi...

editor for creating mathml equations

I don't have much knowledge on mathml editors, we are already using rich:editor to edit html text. I would like to know the most commonly used mathematical equations editor which is browsed based and works across all the major browsers. I have looked at the editors listed here, but unable to make a decision on what to use along with our ...

What is the transformation math for creating a 45 deg angle drop shadow?

I read somewhere in Google's reference (and I can not find it again) that the shadow for the map marker should be at a 45 degree angle. What is the transformation to apply to the original image to achieve this? By eyeball it looks like it could be a horizontal shear of about 50% followed by a vertical compression to 50%, but I suspect it...

Any good java 2d ui's for a custom cms that aren't generally known about?

I am looking for a general java ui that specializes in a cms system that is open source. My main target is just creating a system that children K through 12 can log in, play games, take quizzes, and submit scores to teachers. ...

Determine where line slope changes (algorithm)

If you plot the numbers below, you get a "volatility smile": the numbers follow one linear slope (the left slope), and then change to following another linear slope (the right slope). I have several sets of data like this and want to know where the slope changes. Notes: The slope change usually occurs between points I don't know...

How to find angle of reflected Ray to match a Point

this is for a Tank game I am making Please see pic for a clear idea :link text I want to precompute the exacte angle to hit Point T2. T1:point start T2:point Target V1(a,b):line reflect point : this is what I m looking for :) Edit:it would be cool to see some "Code" :p ...

Limit angle to segment

I need to limit an angle so it fits into a segment. I have drawn and links to a diagram below to better describe what I am after. I am trying to calculate this for a computer program, where I have an angle (slope), and a point (the mouse pointer). The distance does not matter to me, just the angles. If the point is within b1 (green area...

Modulo in order of operation

Where does modulo come in the mathematical order of operation? I am guessing it is similar to division, but before or after? ...

programmatically optimizing expressions (by removing redundant computations)

I had a pretty big equation that I needed to use to solve for a given variable. So I used an online tool that was capable of rewriting an equation in terms of a given variable. It gave me some huge 700 character equation. I tested it, and it does work. I can see some pretty obvious redundancies in the equation where it's recomputing a v...

Calculating interest in objective c?

What is a simple piece of code to read a stored number, calculate interest on the stored value, say $100, at a rate of %10. Then I store the new value in place of the old one. I was working towards this: NSNumber *bankTemp = [[NSNumber alloc] initWithInt:[[NSUserDefaults standardUserDefaults] integerForKey:@"bank"]]; bankTemp = bankTe...

Haskell math performance on multiply-add operation

I'm writing a game in Haskell, and my current pass at the UI involves a lot of procedural generation of geometry. I am currently focused on identifying performance of one particular operation (C-ish pseudocode): Vec4f multiplier, addend; Vec4f vecList[]; for (int i = 0; i < count; i++) vecList[i] = vecList[i] * multiplier + addend; ...

Random Tile layout

I need to place tiles on a large grid radiating from a central point in a way that looks organic and random. New tiles will need to find an open space on the grid that is touching at least 1 other tile. Can anyone point me in the right to direction to anything that might help with this? Or some basic concepts I can read up on that are i...