1
\$\begingroup\$

Consider the following image:

enter image description here

Knowing the (x,y) coordinates of A, B, and C; how would one find the point D? D being the point where line CD cuts the triangle into two smaller right triangles?

I feel like this is elementary, but searching for this is just giving me formulas to find the length of the lines, not the point I am trying to find.

EDIT:

Someone asked before deleting their post if this is a right triangle. Well; it COULD be, but not necessarily.

I should clarify why I need this. I have a quadratic bezier curve, and I want to find this point D on the triangle created by the 3 points (start, end, and control) of the bezier curve. I ultimately intend to check the angles formed by line CD at point C to restrict the "sharpness" of the curve (for road creation)

\$\endgroup\$
1
  • \$\begingroup\$ Hint: you can describe the line CD as starting at C and going in the direction perpendicular to AB. Then, you find where the line CD intersects AB. \$\endgroup\$
    – Alan Wolfe
    Commented Jul 21, 2015 at 22:25

3 Answers 3

2
\$\begingroup\$

First you need to find the slope of the line from A to B, then find the perpendicular slope. Lastly, find where the lines intersect.

The trick is that this is not actually a real triangle problem. Instead, you are trying to find the point on a line that is closest to another point (point C). The point on the line that is closest to the point will /always/ be perpendicular to the line, so yeah. Here's a tutorial on that if you're still confused: https://www.youtube.com/watch?v=NFSdyike7g8

Next time, I believe this would go in the "Mathematics" stack exchange forum.

\$\endgroup\$
3
  • \$\begingroup\$ I actually tried to post this to that stack exchange first, but I do not have the required reputation to post the image :X \$\endgroup\$
    – dmarra
    Commented Jul 21, 2015 at 23:00
  • \$\begingroup\$ Also, this works! thank you for helping to re-frame the question. Thinking of it along these lines helped me to find the answer I was looking for. \$\endgroup\$
    – dmarra
    Commented Jul 21, 2015 at 23:01
  • \$\begingroup\$ Oh. Odd. Well there is always the option of an ascii art maker xD jk anyway, welcome! :) \$\endgroup\$ Commented Jul 21, 2015 at 23:07
1
\$\begingroup\$

No trigonometry is necessary; just a little vector geometry and linear algebra.

Adopt the convention that \$\vec v\$ represents a 2D vector.

Then define two new vectors:

\$\vec c\ = \vec C - \vec A\$ (with coordinates \$c_1\$ and \$c_2\$)
\$\vec b\ = \vec B - \vec A\$ (with coordinates \$b_1\$ and \$b_2\$)

Now considering parameterized equations of:

  • the line segment \$\overline{CD}\$ in terms of \$t\$; and

  • the line segment \$\overline{AB}\$ in terms of \$s\$

yields the following affine matrix equation for the intersection point, \$D\$, of the two lines:

$$ \begin{pmatrix} 0 & t & c_1\\ -t & 0 & c_2 \\ 0 & 0 & 1\end{pmatrix} \times \begin{pmatrix} b_1\\b_2\\1 \end{pmatrix} = \begin{pmatrix} s\cdot b_1\\s\cdot b_2\\1 \end{pmatrix} $$

Solving for the scalar \$s\$ gives:

\$s=(c_1\cdot b_1 - c_2\cdot b_2) / ( (b_1 - b_2) (b_1 + b_2) )\$

The vector formula for \$\vec D\$ is then simply:

\$\vec D=\vec A+s(\vec B-\vec A)\$

\$\endgroup\$
0
\$\begingroup\$

I figure that there's a really efficient way of computing this but I don't have it in my knowledge, but I'll do my best.

ΔXYC is a triangle with vertices on points X, Y and C

VW is a line which starts ands ends in points W and V

^PQR is the angle on point Q that comes and goes to points P and R

Triangles ABC and CDB are congruent, so the scale (Original/Copy) is AB/CB:

We can calculate the length of CD by using the equation :

AC / AB = CD / CB

So CD = (AC * CB) / AB

And

^DCB = ^CAB

To know the angle you can just use law of sines; (Remeber that SIN((90°)) = 1)

[ SIN(^CAB) ] / CB = [SIN (90°)] / AB

SIN(^CAB) = CB * 1 / AB = CB / AB

Now you got your polar coordinates of point D :D

now you just need to convert from polar to Cartesian. Best of luck.

\$\endgroup\$
1
  • \$\begingroup\$ See my answer for a calculation without any trigonometry or polar coordinates. \$\endgroup\$ Commented Jul 22, 2015 at 4:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .