math

Good library for 3D math in C#?

I'm writing a tool that is going to be used to process a bunch of 3D data, doing things like rotating objects, translating, scaling and all that good stuff. Does anyone know of a good library that already does some of this common 3D stuff? I'm not interested in visualizing the data at the moment, and am primarily interested in performin...

C++ - Circular array with lower/upper bounds ?

I want to create something similar to a double linked list (but with arrays) that works with lower/upper bounds. A typical circular array would probably look like: next = (current + 1) % count; previous = (current - 1) % count; But what's the mathematical arithmetic to incorporate lower/upper bounds properly into this ? 0 (lower b...

c# Compact Framework Not Supported Exception on Math.Sinh

Hi! I'm devolping on Compact Framework 2.0 SP1 and when I try to use Math.Sinh it throws me a Not Supported Exception If I can't use this function, is there any other alternative? Thanks! ...

Counting with an Integer Divide-based routine - Is there a formulaic approach?

Consider a routine that counts by successive divide w/ remainder operations. Starting with a 64-bit dividend, the routine divides by a constant divisor. If the remainder is 0, the routine returns. Otherwise, a new dividend is constructed by multiplying the remainder by 2^32 and adding the integer quotient. In code: /// ULong ...

What simple math function f(x) has these properties?

Hello, I have a little math problem. I would like to have a function with these properties: for x much bigger than 0: lim f(x) = x for x much smaller than 0: lim f(x) = 0 and f(0) = 1 (sorry, I had here f(1)=1 which was wrong!) f(x) should be monotonically increasing So the function should look somewhat like this: ^ ...

Reasonable optimized chart scaling.

I need to make a chart with an optimized y axis maximum value. The current method I have of making charts simply uses the maximum value of all the graphs, then divides it by ten, and uses that as grid lines. I didn't write it. Update Note: These graphs have been changed. As soon as I fixed the code, my dynamic graphs started working, ...

Resolving ambiguous categories in an ordered list

Let's take a concrete example and hope I can be clear. Suppose the (ordered) list of months: January < February < March < ... < December (with integers that stand for the months, zero-based), such that Jan is 0, Feb is 1, ..., Dec is 11. Now suppose I do not have access to the full names of months, and am given the followi...

C math calculation not working as expected

I have the following in a program (part of a much larger function, but this is the relevant testing bit): int test = 100 + (100 * (9 / 100)); sprintf (buf, "Test: %d\n\r", test); display_to_pc (buf, player); Basically it amounts to: x = a + (a * (b / 100)) Where a is a given figure, b is a percentage modifier, and x is the result (...

Psuedo-Random-Number-Generator from a computable normal number

Isn't it easily possible to construct a PRNG in such a fashion? Why is it not done? That is, as far as I know we could simply have a PRNG that takes a seed n. When you ask for a random bit, it takes the nth digit of the binary expansion of the computable normal number, and increments n. My first thought was that perhaps we hadn't found...

Scalar triple product and the Determinate

I noticed something when I was trying to solve a problem today. The scalar triple product is the same as the determinant or a three by three matrix with three vectors as rows: A = [a, b, c] det(A) = (a X b) * c I came across this in Real Timer Rendering, and I can't really figure out why this is, or if its even useful. It seems sor...

Aging a dataset

For reasons I'd rather not go into, I need to filter a set of values to reduce jitter. To that end, I need to be able to average a list of numbers, with the most recent having the greatest effect, and the least recent having the smallest effect. I'm using a sample size of 10, but that could easily change at some point. Are there any r...

A simple algorithm for generating positive-semidefinite matrices

I want to generate positive random semi-definite matrices. I am looking for an algorithm or more preferably an simple implementation of the algorithm in C, matlab, java or any language. ...

Determine place values for any base

I'm looking for a function that will determine the value of a place given a number and a base. For example, Given: Whole Value: 1120 Base: 10 Place: Tens place Should return: 2 Does anybody know the math for this? Edit: The function is also expected to pass the whole value numerically, not as a string like "e328fa" or something....

How can I implement this more efficiently

So I have a function (I'm writing this in a pseudo-functional language, I hope its clear): dampen (lr : Num, x : Num) = x + lr*(1-x) And I wish to apply this n times to a value x. I could implement it recursively: dampenN (0, lr, x) = dampen(lr, x) dampenN (n, lr, x) = dampenN(n-1, lr, dampen(x)) But there must be a way I can do i...

Arbitrary precision decimals in C#?

Is there an arbitrary-precision decimal class available for C#? I've seen a couple of arbitrary precision integer classes, but that's not quite the same thing. ...

Best way to search for a saturation value in a sorted list

A question from Math Battle. This particular question was also asked to me in one of my job interviews. " A monkey has two coconuts. It is fooling around by throwing coconut down from the balconies of M-storey building. The monkey wants to know the lowest floor when coconut is broken. What is the minimal number of attempts needed to est...

Calculate Bounding box coordinates from a rotated rectangle, Picture inside.

Hello, I have the coordinates of the top left Point of a rectangle as well as its width, height and rotation from 0 to 180 and -0 to -180. I am trying to get the bounding coordinates of the actual box around the rectangle. What is a simple way of calculating the coordinates of the bounding box - min y, max y, min x, max x ? The A p...

area of intersection between circle and rectangle

i'm looking for a fast way to determine the area of intersection between a rectangle and a circle (I need to do millions of these calculations) A specific property is that in all cases the circle and rectangle always have 2 points of intersection. Java lib would be awesome! Thanks, Britske ...

Separating axis test, detecting if a rotated rectangle overlap an other flat rectangle

Hello, I read about intersection rectangles on: http://stackoverflow.com/questions/115426/algorithm-to-detect-intersection-of-two-rectangles But i have trouble to implement it. If R1 (A,B,C,D) is my rotated rectangle and R2(A',B',C',D') the other rectangle with no rotation. The formula extracted in from the link above is: edge = ...

Project Euler Problem 233

I've decided to tackle Project Euler problem 233 next but I'm having some major problems! I've done some analysis and have made some quite nice progress but I've become stuck now. Here's my working: Lemma 1: Since the circle goes through the 4 corner points there are at least 4 solutions for any n. But for each point on the circumferenc...