I am working with a CAD engine in the head but i working on code only. I have a rectangular tube that need to be put at an angle. I so have the diagonal of the tube where it has to start and stop but i cannot find the long sides. Trying to find the actual side length for the equivalent diagonal and cutting of the tube is pieces i have found myself searching since this morning how to calculate my issue and i found a way to solve this and couple other issues but i don't know how i can find what i am looking for.

What i found is that if i take the central point (x,y) of the diagonal and link the second unknown vertex of the diagonal i obtain an isosceles triangle. I know the diagonal length and the tube width so the side are Diagonal / 2 and tube size in that case 1-1/4 inch. So i know the 3 sides, the end of the diagonal and the center point. i know that knowing all these i still can end up with 2 possible vertex but i know where the good one as to be compared to the 2 points i know.

Knowing this final point will allow me to calculate my actual tube angle compare to the rest of my drawing and size it length wise along that newly found vertex.

My code does not have access to the cad engine per say nor i have any 2d/3d library. So i don't have any fancy methods and i would like to stay away from matrix.

Added image to help show what i am trying to do. enter image description here

What I know : A, B, C, AB, BC and since i know BC ad my tube end 90 degree corner and from C either diagonals will be same length so i have an Isosceles triangle

Therefore i know that CD = CE = BC

BD is variable but known as well

I know that for that diagonal 2 triangles are possible : BCD and BCE but i do know i want the one where the unknown third vertex has to be X < Bx and Y > By. I just don't know how to find those 2 points.

Any clue, ideas, solutions are welcome.

  • $\begingroup$ Can you draw a picture? It’s hard to understand what you want. $\endgroup$
    – Steve Kass
    Jan 28, 2015 at 20:53
  • $\begingroup$ yes i am working on one already. i thought it look complicated without $\endgroup$
    – Franck
    Jan 28, 2015 at 20:55

1 Answer 1


From your setup, say $A=(a_1,a_2)$ and $B=(b_1,b_2)$, and call the "wanted point" W.

You know that $\vec{AB}=(b_1-a_1,b_2-a_2)$ and so $AB$ is inclined by an angle $\arctan(\frac{b_2-a_2}{b_1-a_1})$ to the horizontal. You can compute this angle as a number $\theta$, and $\theta=\angle ABW$.

Now think of the circle centered at $C$ with diameter $d=AB$ and radius $r=\frac{d}{2}$. Notice that $D$ is on this circle, because $\angle ADB$ is a right angle.

Note added: Suppose you only need to find point $D$. It is on the circle, at an angle $\angle BCD$ counterclockwise from point $B$. Note that $\angle BCD=2\angle BAD$, because they are central and exterior angles subtending the same arc of a circle (or look at the isosceles triangle $ACD$). Angle $\sin(\angle BAD)=\frac{1.25}{d}$ (see below).

To find the coordinates of $D=(d_1,d_2)$, if $B=(b_1,b_2)$ and $C=(c_1,c_2)$, use translation and rotation transformations to get

$$d_1=c_1+(b_1-c_1)\cos(\angle BAD)-(b_2-c_2)\sin(\angle BAD)\\ d_1=c_2+(b_1-c_1)\sin(\angle BAD)+(b_2-c_2)\cos(\angle BAD),$$


$$d_1=c_1+(b_1-c_1)\frac{\sqrt{d^2-1.25^2}}{d}-(b_2-c_2)\frac{1.25}{d}\\ d_2=c_2+(b_1-c_1)\frac{1.25}{d}+(b_2-c_2)\frac{\sqrt{d^2-1.25^2}}{d}.$$

You know the length $AB=d$, and you know the length $BD=1.25$. In right triangle $ADB$, then, $\frac{BD}{AB}=\sin(\angle DAB)$, so $\angle DAB=\arcsin\left(\frac{1.25}{d}\right)$ and $\angle ABD=90^{\circ}-\arcsin\left(\frac{1.25}{d}\right)$.

Now $\angle WBD=\angle ABD-\theta$, which you can calculate as a number, and also $\sin \angle WBD=\frac{1.25}{WB}$, which lets you calculate $WB$.

This gives you the amount to subtract from the $x$ coordinate of $B$ to find $W$.

I hope that helps.

  • $\begingroup$ i did not think about the right triangle ADB thanks. $\endgroup$
    – Franck
    Jan 29, 2015 at 13:02
  • $\begingroup$ Can you clarify the part your saying WDB = ABD - 0. I don't get that zero thing and how to get the WB exactly. $\endgroup$
    – Franck
    Jan 29, 2015 at 13:32
  • $\begingroup$ It’s not a zero, it’s a theta: $\theta$. The angle $\theta$ is the inclination of $AB$ to your horizontal, defined in the second paragraph as $\angle ABW$, where $W$ is your "wanted point." (It's also equal to $BWD$ by opposite angles, so it's part of the little triangle at the top that you want to understand.) $\endgroup$
    – Steve Kass
    Jan 29, 2015 at 16:46
  • $\begingroup$ i cannot substract $x$ to $B$ to find $W$, yes they can both have same $Y$ it could be possible but very very unlikely, so far i have only encountered angles. Top and Bottom black rectangle are nearly always NON perpendicular. Knowing $D$ would solve all my issues because i already have line collision methods to find my actual $W$. $D$ will give my the furthest point i can go on that angle and $W$ has to be between $A$ and $D$ $\endgroup$
    – Franck
    Jan 29, 2015 at 18:29
  • $\begingroup$ I added information in my answer that shows how to get $D$ instead of $W$. $\endgroup$
    – Steve Kass
    Jan 29, 2015 at 19:06

You must log in to answer this question.

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