linear-algebra

How do I translate parabolically?

I'm working on an iPhone app with some simple animation. I have a view I want to translate, but not along a line. I want to translate it parabolically. Imagine that I am animating a car moving along a curved road. I know I can set the transform properly to an instance of CGAffineTransform Problem is, I have no idea how to create the ...

Finding a point on a line

I know the start and end points on a line segment. For this example say that the line segment has a distance of 5. Now I want to know the point that has a distance of three away from the end point. Any idea how to do this with math? Start Point (0,0) End Point (0,5) Point I want to find (0,2) ...

Matrix multiplication using matrix template library (MTL 2)

Kindly give me some hint of matrix multiplication using MTL 2. Or any ref. or link for the documentation of MTL 2. ...

Solving vector equations in Mathematica

I'm trying to figure out how to use Mathematica to solve systems of equations where some of the variables and coefficients are vectors. A simple example would be something like where I know A, V, and the magnitude of P, and I have to solve for t and the direction of P. (Basically, given two rays A and B, where I know everything about...

LAPACK + C, weird behaviour

I am trying to solve a simple linear equations system using LAPACK. I use dbsvg method which is optimised for banded matrices. I've obsereved a realy strange behaviour. When I fill the AT matrix this way: for(i=0; i<DIM;i++) AB[0][i] = -1; for(i=0; i<DIM;i++) AB[1][i] = 2; for(i=0; i<DIM;i++) AB[2][i] = -1; for(i=0; i<3; i++) for(j=...

How can I calculate individual point masses?

I am working on a C# 2d soft body physics engine and I need to assign masses to an object's vertices given: a list of vertices (x,y positions), the total mass for the object, and the center of mass. The center of mass is given as: where, R = center of mass M = total mass mj = mass of vertex j rj = position of vertex j I need an al...

Java library for image processing masking task

Is there any handy library can handle masking operation in Java? Taking care of element by element multiplication, masking boundary elements, etc. Thanks! ...

3D Correspondences from fundamental matrix

In MATLAB I have calculated the Fundamental matrix (of two images) using the normalized Eight point algorithm. From that I need to triangulate the corresponding image points in 3D space. From what I understand, to do this I would need the rotation and translation of the image's cameras. The easiest way of course would be calibrate the ca...

What are the pros and cons of using Matrices, Euler Angles, and or Quaternions for rotation representation?

Matrices and Euler angles can suffer from Gimbal lock but what are some other arguments for using one over the other? What do you think DirectX favors? What do you use in daily C++/C/DirectX programming? ...

Minimal linear regression program

Hi, I am running some calculations in an external machine and at the end I get X, Y pairs. I want to apply linear regression and obtain A, B, and R2. In this machine I can not install anything (it runs Linux) and has basic stuff installed on it, python, bash (of course), etc. I wonder what would be the best approach to use a script(pyt...

Triangulation & Direct linear transform

Following Hartley/Zisserman's Multiview Geometery, Algorithm 12: The optimal triangulation method (p318), I got the corresponding image points xhat1 and xhat2 (step 10). In step 11, one needs to compute the 3D point Xhat. One such method is Direct Linear Transform (DLT), mentioned in 12.2 (p312) and 4.1 (p88). The homogenous method (DL...

Haskell linear algebra?

I am starting to test Haskell for linear algebra. Does anyone have any recommendations for the best package for this purpose? Any other good resources for doing basic matrix manipulation with Haskell? The haskell wiki lists several resources for this. My current focus in on hmatrix and bindings-gsl, both of which look promising. ...

General sparse iterative solver libraries

What are some of the better libraries for large sparse iterative (conjugate gradient, MINRES, GMRES, etc.) linear algebra system solving? I've often coded my own routines, but I'm interested to know which "off-the-shelf" packages people prefer. I've heard of PETSc, TAUCS, IML++, and a few others. I'm wondering how these stack up, and ...

System of linear equations in C++?

I need to solve a system of linear equations in my program. Is there a simple linear algebra library for C++, preferably comprised of no more than a few headers? I've been looking for nearly an hour, and all the ones I found require messing around with Linux, compiling DLLs in MinGW, etc. etc. etc. (I'm using Visual Studio 2008.) ...

This is more a matlab/math brain teaser than a question

Here is the setup. No assumptions for the values I am using. n=2; % dimension of vectors x and (square) matrix P r=2; % number of x vectors and P matrices x1 = [3;5] x2 = [9;6] x = cat(2,x1,x2) P1 = [6,11;15,-1] P2 = [2,21;-2,3] P(:,1)=P1(:) P(:,2)=P2(:) modePr = [-.4;16] TransPr=[5.9,0.1;20.2,-4.8] pred_modePr = TransPr'*modePr MixPr...

Metric 3d reconstruction

I'm trying to reconstruct 3D points from 2D image correspondences. My camera is calibrated. The test images are of a checkered cube and correspondences are hand picked. Radial distortion is removed. After triangulation the construction seems to be wrong however. The X and Y values seem to be correct, but the Z values are about the same a...

Efficient 4x4 matrix inverse (affine transform)

Hi, I was hoping someone can point out an efficient formula for 4x4 affine matrix transform. Currently my code uses cofactor expansion and it allocates a temporary array for each cofactor. It's easy to read, but it's slower than it should be. Note, this isn't homework and I know how to work it out manually using 4x4 co-factor expansio...

rotate a plane around a diagonal

I would like to rotate a plane, not around a single (X or Y) axis, but around the diagonal (45 degrees between X and Y). How do I calculate the Rx and Ry given the Rdiagonal? (Rdiagonal is the amount of rotation I would like to achieve around the diagonal axis). To clarify: just take a yellow PostIt and draw cross on it (a horizonal an...

Matrix multiplication using Matrix Template library (MTL 4)

The program is as following: #include <iostream> #include <boost/numeric/mtl/mtl.hpp> using namespace mtl; int main(int argc, char* argv[]) { dense_vector<double> a(5,1.0); dense_vector<double> b(5,2.0); a * trans(b); } I want to calculate a * trans(b), but there is a compling error :C2893. Will someone help me? Thanks a lot! ...

Built in raytracing?

Relating to this question i was wondering if .NET has any libs (or a function) i can use to detect if one point collides with another. I am not sure what angles i should use but is there some function like this func(point src, rect target, angle, distanceOfVision, listPointOrRectOfWalls) Pretty unlikely but i dont know a formula or h...