Geometry with coordinates
Point P = [P x, P y], coordinates P x and P y,
origin O = [0, 0]
Distance between points P = [P x, P y] and
Q = [Qx, Qy]
q
PQ = (Qx − P x)2 + (Qy − P y)2
Ex: if P = [3, 2] and Q = [7, 5], then
q √
PQ = (7 − 3)2 + (5 − 2)2 = 25 = 5
Ex: the intersection point P of the medians
AD, BE and CF of a triangle ABC
(D, E ja F are the middle points of the sides)
Coordinates
Dx = 1
2 (Bx + Cx), Dy = 1 (By + Cy)
2
Ex = 1
2 (Ax + Cx), Dy = 1 (Ay + Cy)
2
Fx = 1
2 (Ax + Bx), F y = 1 (Ay + By)
2
1 (Ax + Bx + Cx)
Px = 3
Py = 1
3 (Ay + By + Cy)
P divides the medians in ratio 2:1 i.e
2 AD, BP = 2 BE, CP = 2 CF
AP = 3 3 3
Polar coordinates r, θ:
r is the distance from the origin O to P
θ is the polar angle of OP (measured from
the positive x-axis)
Kulman θ merkki = sign of angle θ
P x, P y → r, θ:
q
r= P x2 + P y 2
MATLAB/Octave:
θ = atan2d(P y, P x) in degrees −180◦ . . . 180◦
θ = atan2(P y, P x) in radians −π . . . π
(note the order P y, P x !!)
r, θ → P x, P y:
P x = r · cos(θ)
P y = r · sin(θ)
Directed segment from P to Q
length P Q, polar angle θ = θP Q
P x, P y, Qx, Qy → P Q, θ:
q
PQ = (Qx − P x)2 + (Qy − P y)2
θ = atan2(Qy − P y, Qx − P x) (in radians)
θ = atan2d(Qy − P y, Qx − P x) (in degrees)
P x, P y, P Q, θ → Qx, Qy:
Qx = P x + P Q cos(θ)
Qy = P y + P Q sin(θ)
Ex: Given the coordinates of A and B and
distances AP and AQ, calculate the coordi-
nates of P and Q
Polar angles
θ = θAB = atan2d(By − Ay, Bx − Ax)
θAP = θ + 90◦
θAQ = θ − 90◦
Coordinates
P x = Ax + AP cos(θAP )
P y = Ay + AP sin(θAP )
Qx = Ax + AQ cos(θAQ)
Qy = Ay + AQ sin(θAQ)
Ex: The line A, θ through point A with polar
angle θ:
Coordinates of the points P and Q on the line
P x = Ax + r cos(θ)
P y = Ay + r sin(θ)
Qx = Ax − t cos(θ)
Qy = Ay − t sin(θ)
Ex: intersection point P of lines A, θ and B, δ:
P x = Ax + r cos(θ) = Bx + t cos(δ)
P y = Ay + r sin(θ) = By + t sin(δ)
i.e two linear equations for r and t
a b e
z }| { z }| { z }| {
cos(θ) ·r − cos(δ) ·t = Bx − Ax
sin(θ) ·r − sin(δ) ·t = By
| {z } | {z }
− Ay
| {z }
c d f
solution
de − bf af − ce
r= , t=
ad − bc ad − bc
Ex: Positioning from direction measurements
Known base stations A and B, unknown po-
sition P
Measured polar angles θ and δ of P → A and
P →B
P is the intersection point of lines
A, θ and B, δ
Ex: The Steiner point P of a triangle ABC
Triangles ABT , BCR and ACS are equilateral
(i.e AT = BT = AC etc) with 60◦ angles
The sum of distances AP + BP + CP is smal-
lest, angles between P A, P B and P C are 120◦
Polar angles
θAT = θAB − 60◦
θBR = θBC − 60◦
θCS = θCA − 60◦
Coordinates
T x = Ax + AB cos(θAT )
T y = Ay + AB sin(θAT )
Rx = Bx + BC cos(θBC )
Ry = By + BC sin(θBC )
Sx = Cx + CA cos(θCA)
Sy = Cy + CA sin(θCA)
P is the intersection point of lines
A, θAR and B, θBS (and C, θCT )
Ex: Circle, center P , radius r.
Point Q on the circle corresponding angle θ
Qx = P x + r cos(θ)
Qy = P y + r sin(θ)
whole circle: θ = 0 . . . 360◦
arc: θ = θ1 . . . θ2
Ex: Circle through points A, B and C
Center P is the intersection point of the per-
pendicular bisectors of the sides of the triangle
ABC
yhtä kaukana A:sta ja C:stä = at equal dis-
tances from A and C
perpendicular bisector of a segment = a li-
ne through the middle point, perpendicular
to the segment = points which are at equal
distances from the end points
If D, E and F are the middle points of sides
of ABC, then P is the intersection point of
lines
D, θBC + 90◦ and E, θCA + 90◦
(and F, θAB + 90◦)
Ex: Tangents to the circle P, r from a point
A (outside the circle)
Ax, Ay, P x, P y, r → Sx, Sy, T x, T y
q
AS = AT = AP 2 − r2
δ = sin−1(r/AP )
Polar angles:
θAS = θAP + δ
θAT = θAP − δ
Coordinates:
Sx = Ax + AS cos(θAS )
Sy = Ay + AS sin(θAS )
T x = Ax + AT cos(θAT )
T y = Ay + AT sin(θAT )
Ex: Intersection points of a line A, θ and a
circle P, r
Q is the intersection point of lines A, θ and
P, θ + 90◦
Line and circle intersect, if P Q ≤ r. Then
q
QS = QT = r2 − P Q2
and the coordinates of the intersection points
are
Sx = Qx − QS cos(θ)
Sy = Qy − QS sin(θ)
T x = Qx + QT cos(θ)
T y = Qy + QT sin(θ)
Ex: Intersection points of a line P Q and a
triangle ABC
Intersection points S1, S2, S3 of line P, θP Q
and lines A, θAB , B, θBC , C, θCA
S1x = Ax + r1 cos(θAB )
S1y = Ay + r1 sin(θAB )
S2x = Bx + r2 cos(θBC )
S2y = By + r2 sin(θBC )
S3x = Cx + r3 cos(θCA)
S3y = Cy + r3 sin(θCA)
S1 is between A and B, if r1 is 0 . . . AB
S2 is between B and C, if r2 is 0 . . . BC
S3 is between C and A, if r3 is 0 . . . CA
Ex: two-arm robot, given lengths OM and
MP
Direct kinematics: α, β → P x, P y
M x = OM cos(α)
M y = OM sin(α)
P x = M x + M P cos(α + β)
P y = M y + M P sin(α + β)
Inverse kinematics: P x, P y → α, β
q
OP = P x2 + P y 2
θ = atan2d(P y, P x)
OP 2 + OM 2 − M P 2
!
γ = cos−1
2 · OP · OM
α=θ−γ
M P 2 + OM 2 − OP 2
!
β = 180◦ − cos−1
2 · M P · OM
Ex: A mechanism, O and A fixed, OB rotates,
B slides on AC and D moves horizontally:
Given: OA, OB, AC, CD, h and α
Coordinates:
Ax = 0, Ay = −OA
θOB = −90◦ + α
Bx = OB cos(θOB )
By = OB sin(θOB )
θAC = θAB = atan2d(By − Ay, Bx − Ax)
Cx = Ax + AC cos(θAC )
Cy = Ay + AC sin(θAC )
q
Dx = Cx − CD2 − (Dy − Cy)2
Dy = h
Ex. Four-bar mechanism
O and C fixed, lengths OA, AB, BC and OC
OA rotates
If OA is the shortest and OC the longest and
OA + OC ≤ AB + BC
then OA can rotate 360◦ (Grashof condition)
Coordinates: given α
Ox = 0, Oy = 0
Cx = OC, Cy = 0
Ax = OA cos(α), Ay = OA sin(α)
q
AC = (Ax − Cx)2 + (Ay − Cy)2
θ = θCA = atan2 (Ay − Cy, Ax − Cx)
AC 2 + BC 2 − AB 2
!
ϕ = cos−1
2 · AC · BC
β =θ−ϕ
Bx = Cx + BC cos(β), By = Cy + BC sin(β)