1
$\begingroup$

In the example picture below, I know the points $A$, $B$, $C$ & $D$. How would I go about calculating $x$, $y$, $z$ & $w$ and $O$, but as points on the actual plane itself (e.g. treating $D$ as $(0, 0)$, $A$ as $(0, 1)$, $C$ as $(1, 0)$ and $B$ as $(1, 1)$.

enter image description here

Ultimately I need to be able to calculate any arbitrary point on the plane so I'm unsure as to whether this would be possible through linear interpolation of the results above or whether I would actually just have to do this via some form of Matrix calculation? I don't really know matrix math at all!

Just looking for something I can implement in JavaScript (in an enviroment that does support matricies).

  • 1
    Thanks very $m$uch! I'm $n$ot sure why I did$n$'t just see this. It certainly works to calculate the points (and I can happily work out the points relative to the plane). However this $m$ethod of just using points hasn't helped me when interpolated across the whole plane for many points, so now I guess I'm going to have to bite the biscuit and go for a matrix projected transformation instead.2011-08-28

2 Answers 2

1

This should be done in terms of plane projective geometry. This means you have to introduce homogeneous coordinates. The given points $A=(a_1,a_2)$, $\ldots$, and $D=(d_1,d_2)$ have "old" homogeneous coordinates $(a_1,a_2, 1)$, $\ldots$, and $(d_1,d_2,1)$ and should get "new" homogeneous coordinates $\alpha(0,1,1)$, $\beta(1,1,1)$, $\gamma(1,0,1)$, and $\delta(0,0,1)$. There is a certain $(3\times 3)$-matrix $P:=[p_{ik}]$ (determined up to an overall factor) that transforms the old coordinates into the new ones. To find this matrix you have twelve linear equations in thirteen variables which is just right for our purpose. (The values of $\alpha$, $\ldots$, $\delta$ are not needed in the sequel.)

After the matrix $P$ has been determined the new affine coordinates $(\bar x, \bar y)$ of any point $(x,y)$ in the drawing plane are obtained by applying $P$ to the column vector $(x,y,1)$. This results in a triple (x',y',z'), whereupon one has \bar x={x'\over z'}\ ,\quad \bar y={y'\over z'}\ .

0

This isn't so bad, so that's good. Your suggested set of points, however, do not submit to the same sort of analysis as what I'm about to give because it's a square - so the sides are parallel (so the f1 and f2 are... inconvenient, even in the projective plane; if you know projective geometry, mention it, and I'll update).

The general process is to find the equations of lines, find where they intersect, and then make more lines, and find where they intersect. Ok? Great.

First, the point $O$ is nothing more than the midpoint of DB. Perhaps the figure in general is not symmetric, in which case it's the intersection of DB and AC. Say the coordinates of A are $\left[ \begin{array}{cc} a_x \\ a_y \end{array} \right]$, the coordinates of B are $\left[ \begin{array}{cc} b_x \\ b_y \end{array} \right]$ and so on.

Then the lines DB and AC can be parameterized by the equations

$\overline{DB} = \left[ \begin{array}{cc} b_x \\ b_y \end{array} \right] + \left( \left[ \begin{array}{cc} d_x \\ b_y \end{array} \right] - \left[ \begin{array}{cc} b_x \\ b_y \end{array} \right] \right)t$

$\overline{AC} = \left[ \begin{array}{cc} a_x \\ a_y \end{array} \right] + \left( \left[ \begin{array}{cc} c_x \\ c_y \end{array} \right] - \left[ \begin{array}{cc} a_x \\ a_y \end{array} \right] \right)s$

Now you set equal and solve for s and t. How? Considering x and y components separately, you have two equations in 2 variables - use a matrix.

$\left[ \begin{array}{cc} d_x - b_x & c_x - a_x \\ d_y - b_y & c_y - a_y \end{array} \right] \left[ \begin{array}{cc} t \\ s \end{array} \right] = \left[ \begin{array}{cc} b_x - a_x \\ b_y - a_y \end{array} \right]$

And this procedure will give you the intersection of those two lines. In fact, this will give you the intersection between any two non-parallel lines. Good.

So with this, we found the point $O$. Do this with the lines AD and BC to find their focal point, f2. Repeat with the lines AD and BC to find their focal point, f1. Then we can repeat with the lines $\overline{f_1O}$ and $\overline{AD}$ to find z. $\overline{f_1O}$ and $\overline{BC}$ to find x. And because I've given almost everything away, rinse, wash, and repeat for w and y.

Does that make sense?

  • 0
    Hmmm I think I'm attempting this in the wrong way. Basically I have a shape with points A, B, C, D on my computer screen. I'm attempting to fake perspective onto it by distorting the texture. So the point O for the texture would normally be (0.5, 0,5). I'd like to work out how I translate that so it appears to be further into the distance. So in the example picture O would have coordinates closer to A (which in texture coordinates is (0, 1) even though it has screen coordinates of different values. Does that make any more sense?2011-08-30