math

How can I find the arctan of a right triangle using only the hypotenuse?

Okay, so I need to make C go the shortest path from A to B. A to B is the hypotenuse of my right triangle, and I need to give C the arctan of said triangle. How do I do this, and does the formula have a name? ...

triangulating gps coordinates

Say you have n GPS coordinates how could you work out the central gps point between them? ...

What does matrix*vector mean in contrast to vector*matrix

if I do positionVector*worldMatrix the position is transformed into world space. But what happens if I do it the other way around (worldMatrix*positionVector) in terms of 3d space? I noticed the result is different to the first one. I already googled about matrix, math they explain a lot but not this one, at least I couldn't find it. ...

Implementing ridge detection

I'm trying to write a ridge detection algorithm, and all of the sources I've found seem to conflate edge detection with ridge detection. Right now, I've implemented the Canny edge detection algorithm, but it's not what I want: for example, given a single line in the image, it will effectively translate it to a double line of edges (since...

Fraction length

How to get the fraction length? If at all possible, without using string operation or loop should all return length of 3: 5.234 5.23400 5.234000 Any programming language is accepted [EDIT] Not a homework, I want to display fractions at its minimum. Example, I defined numeric(18,8) in database. If the user entered only 5.234, the d...

How to choose group of numbers in the vector

I have an application with some probabilities of measured features. I want to select n-best features from vector. I have a vector of real numbers. Vector is normalized, sum of all numbers is 1 (it is probability of some features). I want to select group of n less than N (assume approx. 8) largest numbers. Numbers has to be close togethe...

Matrix operations to enumerate all paths through n-partite graph

I have an n-partite (undirected) graph, given as an adjacency matrix, for instance this one here: a b c d a 0 1 1 0 b 0 0 0 1 c 0 0 0 1 d 0 0 0 0 I would like to know if there is a set of matrix operations that I can apply to this matrix, which will result in a matrix that "lists" all paths (of length n, i.e. through all the partit...

Is JavaScript's Math broken?

0.1 + 0.2 == 0.3 // returns false 0.1 + 0.2 // returns 0.30000000000000004 Any ideas why this happens? ...

Possible infinite loop on math equation?

I have the following problem, and am having trouble understanding part of the equation: Monte Carlo methods to estimate an integral is basically, take a lot of random samples and determined a weighted average. For example, the integral of f(x) can be estimated from N independent random samples xr by for a uniform probability distribu...

reverse perspective projection

I'm using worldview_inverse * (projection_inverse * vector) to transform screen space coordinates into world space coordinates. I assumed that (x,y,1,1) would transform to a point on the far plane, while (x,y,-1,1) transforms to a point on the near plane, and connecting the line I can query all objects in the view frustum that ...

Python for mathematics students ?

I need to deliver one and half hour seminar on programming for students at the department of mathematics. I have chosen python as language. What should be content of my presentation ? What are good resources available ? What is necessity of programming for maths students? How will knowledge of programming will help them? Thank you...

What operation turns floating point numbers into a "group" ?

Might anyone be famiiar with tricks and techniques to coerce the set of valid floating point numbers to be a group under a multiplication based operation? That is, given any two floating point numbers ("double a,b"), what sequence of operations, including multiply, will turn this into another valid floating point number? (A valid floa...

number of possible combinations in a partitioning

Given is a set S of size n, which is partitioned into classes (s1,..,sk) of sizes n1,..,nk. Naturally, it holds that n = n1+...+nk. I am interested in finding out the number of ways in which I can combine elements of this partitioning so that each combination contains exactly one element of each class. Since I can choose n1 elements fr...

WPF: Collision Detection with Rotated Squares

With reference to this programming game I am currently building. Thanks to the answers from this post, I am now able to find the x-y coordinates of all the points of the rectangles (even when rotated), and Collision-Detection with Walls is almost working perfectly now. Now I need to implement collision detection with the bots themselve...

Types for large numbers

I am working on an app that will need to handle very large numbers. I checked out a few available LargeNumber classes and have found a few that I am happy with. I have a class for large integers and for large floating point numbers. Since some of the numbers will be small and some large the question is whether it is worth checking the ...

How to check if a number is a power of 2

Today I needed a simple algorithm for checking if a number is a power of 2. The algorithm needs to be: Simple Correct for any ulong value. I came up with this simple algorithm: private bool IsPowerOfTwo(ulong number) { if (number == 0) return false; for (ulong power = 1; power > 0; power = power << 1) { ...

How to handle a translation Matrix in an inverted Y axis point of view

My usercase is an iphone application where I do an animation on the scale, rotation and translation of an image. So, I concat everything and feed it to the transform property, but there is one problem: Since my images vary in size, it is a problem to position them correctly. I'm used to an inverted y axis coordinate system, so I want m...

LaTex macro to make LaTex more human-friendly in Math?

How can I make a LaTex macro which replaces each \and by the word "and" \or by the word "or" so that the nouns are not in italics? ...

Fixed point math in c#?

Hi there, I was wondering if anyone here knows of any good resources for fixed point math in c#? I've seen things like this (http://2ddev.72dpiarmy.com/viewtopic.php?id=156) and this (http://stackoverflow.com/questions/79677/whats-the-best-way-to-do-fixed-point-math), and a number of discussions about whether decimal is really fixed poin...

Does casting to an int after std::floor guarantee the right result?

I'd like a floor function with the syntax int floor(double x); but std::floor returns a double. Is static_cast <int> (std::floor(x)); guaranteed to give me the correct integer, or could I have an off-by-one problem? It seems to work, but I'd like to know for sure. For bonus points, why the heck does std::floor return a double in t...