## Perpendicular on a line from a given point

I solved the equations for you: k = ((y2-y1) * (x3-x1) – (x2-x1) * (y3-y1)) / ((y2-y1)^2 + (x2-x1)^2) x4 = x3 – k * (y2-y1) y4 = y3 + k * (x2-x1) Where ^2 means squared

## Find point of intersection between two vectors in MATLAB

One solution is to use the equations derived in this tutorial for finding the intersection point of two lines in 2-D (update: this is an internet archive link since the site no longer exists). You can first create two matrices: one to hold the x coordinates of the line endpoints and one to hold the … Read more

## Calculate second point knowing the starting point and distance

It seems you are measuring distance (R) in meters, and bearing (theta) counterclockwise from due east. And for your purposes (hundereds of meters), plane geometry should be accurate enough. In that case, dx = R*cos(theta) ; theta measured counterclockwise from due east dy = R*sin(theta) ; dx, dy same units as R If theta is … Read more

## How to distribute points evenly on the surface of hyperspheres in higher dimensions?

Very interesting question. I wanted to implement this into mine 4D rendering engine as I was curious how would it look like but I was too lazy and incompetent to handle ND transcendent problems from the math side. Instead I come up with different solution to this problem. Its not a Fibonaci Latice !!! Instead … Read more

## Solving a linear equation

Cramer’s Rule and Gaussian Elimination are two good, general-purpose algorithms (also see Simultaneous Linear Equations). If you’re looking for code, check out GiNaC, Maxima, and SymbolicC++ (depending on your licensing requirements, of course). EDIT: I know you’re working in C land, but I also have to put in a good word for SymPy (a computer … Read more

## Can a IEEE 754 real number “cover” all integers within its range?

No, not all, but there exists a range within which you can represent all integers accurately. Structure of 32bit floating point numbers The 32bit floating point type uses 1 bit for the sign 8 bits for the exponent 23 bits for the fraction (leading 1 implied) Representing numbers Basically, you have a number in the … Read more

## How to calculate Tangent and Binormal?

The relevant input data to your problem are the texture coordinates. Tangent and Binormal are vectors locally parallel to the object’s surface. And in the case of normal mapping they’re describing the local orientation of the normal texture. So you have to calculate the direction (in the model’s space) in which the texturing vectors point. … Read more

## Fitting polynomials to data

Thanks for everyone’s replies. Here is another attempt at summarizing them. Pardon if I say too many “obvious” things: I knew nothing about least squares before, so everything was new to me. NOT polynomial interpolation Polynomial interpolation is fitting a polynomial of degree n given n+1 data points, e.g. finding a cubic that passes exactly … Read more

## Evaluating a string of simple mathematical expressions [closed]

Assembler 427 bytes Obfuscated, assembled with the excellent A86 into a .com executable: dd 0db9b1f89h, 081bee3h, 0e8af789h, 0d9080080h, 0bdac7674h, 013b40286h dd 07400463ah, 0ccfe4508h, 08ce9f675h, 02fc8000h, 013b0057eh, 0feaac42ah dd 0bedf75c9h, 0ba680081h, 04de801h, 04874f73bh, 04474103ch, 0e8e8b60fh dd 08e8a003fh, 0e880290h, 0de0153h, 08b57e6ebh, 0d902a93eh, 046d891dh dd 08906c783h, 05f02a93eh, 03cffcee8h, 057197510h, 02a93e8bh, 08b06ef83h dd 05d9046dh, 02a93e89h, 03bc9d95fh, 0ac0174f7h, 074f73bc3h, 0f3cac24h … Read more