math

Rotation matrix for direction vector

I've been playing with some algorithms on the internet for a while and I can't seem to get them to work, so I'm tossing the question out here; I am attempting to render a velocity vector line from a point. Drawing the line isn't difficult: just insert a line with length velocity.length into the graph. This puts the line centered at the ...

A good Java library for network math

I'm looking for a Java library that is geared towards network math and already tested. Nothing particularly fancy, just something to hold ips and subnets, and do things like print a subnet mask or calculate whether an IP is within a given subnet. Should I roll my own, or is there already a robust library for this? ...

Triangle mathematics for game development

I'm trying to make a triangle (isosceles triangle) to move around the screen and at the same time slightly rotate it when a user presses a directional key (like right or left). I would like the nose (top point) of the triangle to lead the triangle at all times. (Like that old asteroids game). My problem is with the maths behind this. A...

What sort of mathematics do you use in your .Net app?

Excluding everything that's in System.Math. I think that System.Math is woefully inadequate. For example, in several official .Net frameworks, I can count 3 different implementations of matrices. Same goes for vectors. One implementation of a complex number; several different implementations of arbitrary rational numbers, and so on. So...

Books on animation, recommendations?

I would like to better understand the math behind animations, 3d and 2d. I recently came across this example via Digg. http://maettig.com/code/javascript/3d_dots.html It is pretty interesting and another animation experiment on the same site is just as impressive. http://maettig.com/code/javascript/swirl.html With FF 3.1 and WebKit-b...

Find number range intersection

What is the best way to find out whether two number ranges intersect? My number range is 3023-7430, now I want to test which of the following number ranges intersect with it: <3000, 3000-6000, 6000-8000, 8000-10000, >10000. The answer should be 3000-6000 and 6000-8000. What's the nice, efficient mathematical way to do this in any progr...

Optimal Rectangle hatching algorithm

Hi, I am looking for an algorithm to hatch a rectangle with shortest overall line length, so that an object of given area can be passed through the hatching. For example given a rectangle of 5x3 cm, and I hatch using parallel lines 1cm across, the biggest object I can pass through the hatch is a square of 1cm side. I have used an overa...

Drawing an iso line of a 2D implicit scalar field

I have an implicit scalar field defined in 2D, for every point in 2D I can make it compute an exact scalar value but its a somewhat complex computation. I would like to draw an iso-line of that surface, say the line of the '0' value. The function itself is continuous but the '0' iso-line can have multiple continuous instances and it is n...

Is it possible to translate a user-entered mathematical equation into C# code at runtime?

I would like to allow the user to enter any equation, like the following, into a text box: x = x / 2 * 0.07914 x = x^2 / 5 And have that equation applied to telemetry data that is coming from a device connected via a serial port. The incoming data points are represented by x and each data point is processed by the user-specified equa...

How to embed AsciiMathML in Google Sites?

We would need to embed mathematical formulas through AsciiMathML into Google Sites pages (internal wiki for a research team). I am stuck with the limitation of Google Sites. Any idea how to do that? (ps: I have finally found a poorly practical work-around, but better ideas would still be appreciated) ...

Best way to find all factors of a given number in C#

All numbers that divide evenly into x. I put in 4 it returns: 4, 2, 1 edit: I know it sounds homeworky. I'm writing a little app to populate some product tables with semi random test data. Two of the properties are ItemMaximum and Item Multiplier. I need to make sure that the multiplier does not create an illogical situation where b...

random number with ratio 1:2

I have to generate two random sets of matrices Each containing 3 digit numbers ranging from 2 - 10 like that matrix 1: 994,878,129,121 matrix 2: 272,794,378,212 the numbers in both matrices have to be greater then 100 and less then 999 BUT the mean for both matrices has to be in the ratio of 1:2 or 2:3 what ever c...

How to determine path from noisy X, Y data

I have an unsorted list of noisy X, Y points. They do, however, form a path through the world. I would like an algorithm to draw an approximation of this data using line segments. This is similar to how you would use a line -fitting algorithm to pick an approximation of linear data. My problem is only harder because the path bends and w...

Algorithm: Voyage planning

I need to plan a voyage connecting n locations in the sea with a specified origin and specified destination with following constraints. The voyage has to touch all locations. If there is a reservation from A to B then a has to be touched before B The time spend at each location varies (depends upon the reservations to that location) Eac...

Math: Factorisation

Omitting details of methods to calculate primes, and methods of factorisation. Why bother to factorise ? What are its applications ? ...

Why C++ cannot be parsed with a LR(1) parser?

I were reading about parsers and parser generators when I hit upon this statement in wikipedia's LR parsing -page: "Many programming languages can be parsed using some variation of an LR parser. One notable exception is C++." Why is it so? What particular property in C++ causes it to be impossible to parse with LR parsers? I first tri...

Calculating a 2D Vector's Cross Product

From wikipedia: the cross product is a binary operation on two vectors in a three-dimensional Euclidean space that results in another vector which is perpendicular to the plane containing the two input vectors. Given that the definition requires at least three dimensions, how does one calculate the cross product of two 2d vectors?...

How do I get the "reverse" tangent in objective-c?

I know that tan(angle) gets me the tangent. But how do I do the "reverse tangent" so that I can get the angle given the length of both sides of the right triangle? I'm assuming there is a method for this in Math.h? ...

Integer math in c#

I have a menu of product brands that I want to split over 4 columns. So if I have 39 brands, then I want the maximum item count for each column to be 10 (with a single gap in the last column. Here's how I'm calculating the item count for a column (using C#): int ItemCount = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(BrandCount) / ...

Stacking rectangles to take as little space as possible

Hello there I have a program that will calculate the minimal area taken by fitting rectangles together. Input: Rectangles of different height and width. Output: One rectangle that contains all these rectangles. Rules: One cannot turn or roll the rectangles around and they cannot overlap. I understand that this is related or is possibl...