math

Position of connected points in space

Hi, A-B-C-D are 4 points. We define r = length(B-C), angle, ang1 = (A-B-C) and angle ang2 = (B-C-D) and the torsion angle tors1 = (A-B-C-D). What I really need to do is to find the coordinates of C and D provided that I have the new values of r, ang1, ang2 and tors1. The thing is that the points A and B are rigidly connected to each ot...

Minimum perpendicular Distance of a point to a line in 3D plane algorithm

How to find the minimum perpendicular distance of point from a line in 3D plane? Please give me the logic and I will try to code on myself. Please let me know how to do it in terms of x,y,z that is in terms of coordinate systems. I am finding it a bit difficult to find the right solution which will be easy from a coding point of view....

inverse FFT in shader language?

Hi, does anyone know an implementation of the inverse FFT in HLSL/GLSL/cg ... ? It would save me much work. Best, heinrich ...

Project a grid in screenspace on the world xz plane.

Hi, I want to project a grid on the xz-plane like shown here: http://habibs.files.wordpress.com/2009/07/2-1.jpg To do that, I created a vertex grid with x and z range [-1|1]. In the shader I multiply the xz screen coordinate of a vertex with the inverse of the View-Projection matrix. Then I want to adjust the height, depending on the n...

Rotation matrix that minimizes distance

Let's say I have two points in 3D space (a and b) and a fixed axis/unit vector called n. I want to create a rotation matrix that minimizes the euclidan distance between point a (unrotated) and the rotated point b. E.g: Q := matrix_from_axis_and_angle (n, alpha); find the unknown alpha that minimizes sqrt(|a - b*Q|) Btw - If a s...

Generic applet style system for publishing mathematics demonstrations?

Anyone who's tried to study mathematics using online resources will have come across these Java applets that demonstrate a particular mathematical idea. Examples: http://www.math.ucla.edu/~tao/java/Mobius.html http://www.mathcs.org/java/programs/FFT/index.html I love the idea of this interactive approach because I believe it is very ...

How can I convert coordinates on a square to coordinates on a circle?

I'm developing an indie video game, and have been operating under the assumption that because the thumbstick on my controller has a circular range of motion, it returns "circular" coordinates; that is, Cartesian coordinates constrained to a circular area (of radius 1). In fact, the coordinates are "square"; e.g., the top-right thumbstick...

I want to move from web dev into something more math-based. Any suggestions?

I've been doing Rails for some time now, and, as the title suggests, I'm pretty bored with it. In the mean time, I've been very much attracted to mathematics, particularly logic, but also geometry, abstract algebra, combinatorics and graph theory, differential equations.. I enjoy pretty much all of it.. My main goal is to read lots of ...

I have a struct, but I don't know how to use it...

typedef struct Complex{ double real; int img; } Complex; I've seen people use it as a type like: Complex sqrt( double x) { } how do 'real' and 'img' play a role in this type of function? Thanks ...

(all the) directions perpendicular to hyperplane through p data points

Hi people, I have a simple question: given p points (non-collinear) in R^p i find the hyperplane passing by these points (to help clarify i type everything in R): p<-2 x<-matrix(rnorm(p^2),p,p) b<-solve(crossprod(cbind(1,x[,-2])))%*%crossprod(cbind(1,x[,-2]),x[,2]) then, given a p+1^th points not collinear with first p points, i fin...

C# Normal Random Number

I would like to create a function that accepts Double mean, Double deviation and returns a random number with a normal distribution. Example: if I pass in 5.00 as the mean and 2.00 as the deviation, 68% of the time I will get a number between 3.00 and 7.00 My statistics is a little weak…. Anyone have an idea how I should approach thi...

Geometric sequence puzzler

The following problem has been puzzling me for a couple of days (nb: this is not homework). There exists two geometric sequences that sum to 9. The value of their second term (t2) is 2. Find the common ratio (r) Find the first element (t1) of each The answers to (1) are 2/3 and 1/3 and the answers to (2) are 3 and 6 respectively. U...

Generated methods for polynomial evaluation

I'm trying to come up with an elegant way to handle some generated polynomials. Here's the situation we'll focus on (exclusively) for this question: order is a parameter in generating an nth order polynomial, where n:=order + 1. i is an integer parameter in the range 0..n The polynomial has zeros at x_j, where j = 1..n and j ≠ i (it sh...

Can you do Vector addition in Java, natively?

I Know there's a "Vector" class in java, but it seems to be just a simpler ArrayList type of deal, not an actual, mathematical Vector (as in a magnitude and a direction). Is there any way to do Vector manipulations (particularly addition) in Java? Or am I stuck on my own having to implement it or use a third party module? -Jenny ...

Natural logarithm method for NSNumber and NSDecimalNumber

I've got some C# code that I'm converting to Objective-C. In C# I would call Math.Log(). I'm slowly learning that some people stick to C functions/types and only use NSNumber etc when they need to interop with Cocoa. Is there an equivalent for ObjC/Cocoa, or do I need to drop into C to do this? I need my code to be as accurate as possib...

Mathematical notation of programming concepts

There are many methods for representing structure of a program (like UML class diagrams etc.). I am interested if there is a convention which describes programs in a strict, mathematical way. I am especially interested in the use of mathematical notation for this purpose. An example: Classes are represented as sets (fields, properties) ...

WolframAlpha: Solve Multiple Functions

I'm trying to use WolframAlpha to solve for a variable. I have u(k, r) = (900-3k)r^(k-1) and s(n, r) = sum u(k, r), k=1 to n and I want to solve for r with s(5000, r) = -600000000000 I've tried various incantations, but can't seem to get it working. I can't even get s defined to evaluate it. If you care, it is to solve this pr...

Given an angle and length, how do I calculate the coordinates

Assuming the upper left corner is (0,0) and I'm given an angle of 30 degrees, a starting point of (0,300), a line length of 600, how do I calculate the ending point of the line so that the line is representative of the angle given. The C pseudo-code is main() { int x,y; getEndPoint(30, 600, 0, 300, &x, &y); printf("end x=%d, en...

How to use correlogram to estimate variance?

From a book of computer simulation, I got this two equation. The first is to calculate correlogram, the second is how to use correlogram to estimate variance. The common approach to estimate variance of observation is often not incorrect in computer simulation because observations are often related. My question is, the value I calcu...

Javascript math show decimal places

Hi.. I almost have this working however the script is rounding my numbers while I wish to keep both decimals places for a full price instead of being automatically rounded up. My sandbox for this script is here: http://www.zacharydesigns.com/sandbox/calculatorJS2.html and here is the code: <script type="text/javascript"> functi...