# Euclidean spaces #

This file makes some definitions and proves very basic geometrical results about real inner product spaces and Euclidean affine spaces. Results about real inner product spaces that involve the norm and inner product but not angles generally go in Analysis.NormedSpace.InnerProduct. Results with longer proofs or more geometrical content generally go in separate files.

## Main definitions #

• EuclideanGeometry.orthogonalProjection is the orthogonal projection of a point onto an affine subspace.

• EuclideanGeometry.reflection is the reflection of a point in an affine subspace.

## Implementation notes #

To declare P as the type of points in a Euclidean affine space with V as the type of vectors, use [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] [NormedAddTorsor V P]. This works better with outParam to make V implicit in most cases than having a separate type alias for Euclidean affine spaces.

Rather than requiring Euclidean affine spaces to be finite-dimensional (as in the definition on Wikipedia), this is specified only for those theorems that need it.

## References #

• https://en.wikipedia.org/wiki/Euclidean_space

### Geometrical results on Euclidean affine spaces #

This section develops some geometrical definitions and results on Euclidean affine spaces.

theorem EuclideanGeometry.dist_left_midpoint_eq_dist_right_midpoint {V : Type u_1} {P : Type u_2} [] [] [] (p1 : P) (p2 : P) :
dist p1 (midpoint p1 p2) = dist p2 (midpoint p1 p2)

The midpoint of the segment AB is the same distance from A as it is from B.

theorem EuclideanGeometry.inner_weightedVSub {V : Type u_1} {P : Type u_2} [] [] [] {ι₁ : Type u_3} {s₁ : Finset ι₁} {w₁ : ι₁} (p₁ : ι₁P) (h₁ : (s₁.sum fun (i : ι₁) => w₁ i) = 0) {ι₂ : Type u_4} {s₂ : Finset ι₂} {w₂ : ι₂} (p₂ : ι₂P) (h₂ : (s₂.sum fun (i : ι₂) => w₂ i) = 0) :
(s₁.weightedVSub p₁) w₁, (s₂.weightedVSub p₂) w₂⟫_ = (-s₁.sum fun (i₁ : ι₁) => s₂.sum fun (i₂ : ι₂) => w₁ i₁ * w₂ i₂ * (dist (p₁ i₁) (p₂ i₂) * dist (p₁ i₁) (p₂ i₂))) / 2

The inner product of two vectors given with weightedVSub, in terms of the pairwise distances.

theorem EuclideanGeometry.dist_affineCombination {V : Type u_1} {P : Type u_2} [] [] [] {ι : Type u_3} {s : } {w₁ : ι} {w₂ : ι} (p : ιP) (h₁ : (s.sum fun (i : ι) => w₁ i) = 1) (h₂ : (s.sum fun (i : ι) => w₂ i) = 1) :
let_fun a₁ := () w₁; let_fun a₂ := () w₂; dist a₁ a₂ * dist a₁ a₂ = (-s.sum fun (i₁ : ι) => s.sum fun (i₂ : ι) => (w₁ - w₂) i₁ * (w₁ - w₂) i₂ * (dist (p i₁) (p i₂) * dist (p i₁) (p i₂))) / 2

The distance between two points given with affineCombination, in terms of the pairwise distances between the points in that combination.

theorem EuclideanGeometry.dist_smul_vadd_sq {V : Type u_1} {P : Type u_2} [] [] [] (r : ) (v : V) (p₁ : P) (p₂ : P) :
dist (r v +ᵥ p₁) p₂ * dist (r v +ᵥ p₁) p₂ = v, v⟫_ * r * r + 2 * v, p₁ -ᵥ p₂⟫_ * r + p₁ -ᵥ p₂, p₁ -ᵥ p₂⟫_

The squared distance between points on a line (expressed as a multiple of a fixed vector added to a point) and another point, expressed as a quadratic.

theorem EuclideanGeometry.dist_smul_vadd_eq_dist {V : Type u_1} {P : Type u_2} [] [] [] {v : V} (p₁ : P) (p₂ : P) (hv : v 0) (r : ) :
dist (r v +ᵥ p₁) p₂ = dist p₁ p₂ r = 0 r = -2 * v, p₁ -ᵥ p₂⟫_ / v, v⟫_

The condition for two points on a line to be equidistant from another point.

theorem EuclideanGeometry.eq_of_dist_eq_of_dist_eq_of_mem_of_finrank_eq_two {V : Type u_1} {P : Type u_2} [] [] [] {s : } [FiniteDimensional s.direction] (hd : FiniteDimensional.finrank s.direction = 2) {c₁ : P} {c₂ : P} {p₁ : P} {p₂ : P} {p : P} (hc₁s : c₁ s) (hc₂s : c₂ s) (hp₁s : p₁ s) (hp₂s : p₂ s) (hps : p s) {r₁ : } {r₂ : } (hc : c₁ c₂) (hp : p₁ p₂) (hp₁c₁ : dist p₁ c₁ = r₁) (hp₂c₁ : dist p₂ c₁ = r₁) (hpc₁ : dist p c₁ = r₁) (hp₁c₂ : dist p₁ c₂ = r₂) (hp₂c₂ : dist p₂ c₂ = r₂) (hpc₂ : dist p c₂ = r₂) :
p = p₁ p = p₂

Distances r₁ r₂ of p from two different points c₁ c₂ determine at most two points p₁ p₂ in a two-dimensional subspace containing those points (two circles intersect in at most two points).

theorem EuclideanGeometry.eq_of_dist_eq_of_dist_eq_of_finrank_eq_two {V : Type u_1} {P : Type u_2} [] [] [] [] (hd : ) {c₁ : P} {c₂ : P} {p₁ : P} {p₂ : P} {p : P} {r₁ : } {r₂ : } (hc : c₁ c₂) (hp : p₁ p₂) (hp₁c₁ : dist p₁ c₁ = r₁) (hp₂c₁ : dist p₂ c₁ = r₁) (hpc₁ : dist p c₁ = r₁) (hp₁c₂ : dist p₁ c₂ = r₂) (hp₂c₂ : dist p₂ c₂ = r₂) (hpc₂ : dist p c₂ = r₂) :
p = p₁ p = p₂

Distances r₁ r₂ of p from two different points c₁ c₂ determine at most two points p₁ p₂ in two-dimensional space (two circles intersect in at most two points).

def EuclideanGeometry.orthogonalProjectionFn {V : Type u_1} {P : Type u_2} [] [] [] (s : ) [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) :
P

The orthogonal projection of a point onto a nonempty affine subspace, whose direction is complete, as an unbundled function. This definition is only intended for use in setting up the bundled version orthogonalProjection and should not be used once that is defined.

Equations
Instances For
theorem EuclideanGeometry.inter_eq_singleton_orthogonalProjectionFn {V : Type u_1} {P : Type u_2} [] [] [] {s : } [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) :
s (AffineSubspace.mk' p s.direction) =

The intersection of the subspace and the orthogonal subspace through the given point is the orthogonalProjectionFn of that point onto the subspace. This lemma is only intended for use in setting up the bundled version and should not be used once that is defined.

theorem EuclideanGeometry.orthogonalProjectionFn_mem {V : Type u_1} {P : Type u_2} [] [] [] {s : } [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) :

The orthogonalProjectionFn lies in the given subspace. This lemma is only intended for use in setting up the bundled version and should not be used once that is defined.

theorem EuclideanGeometry.orthogonalProjectionFn_mem_orthogonal {V : Type u_1} {P : Type u_2} [] [] [] {s : } [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) :
AffineSubspace.mk' p s.direction

The orthogonalProjectionFn lies in the orthogonal subspace. This lemma is only intended for use in setting up the bundled version and should not be used once that is defined.

theorem EuclideanGeometry.orthogonalProjectionFn_vsub_mem_direction_orthogonal {V : Type u_1} {P : Type u_2} [] [] [] {s : } [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) :
s.direction

Subtracting p from its orthogonalProjectionFn produces a result in the orthogonal direction. This lemma is only intended for use in setting up the bundled version and should not be used once that is defined.

def EuclideanGeometry.orthogonalProjection {V : Type u_1} {P : Type u_2} [] [] [] (s : ) [Nonempty s] [HasOrthogonalProjection s.direction] :

The orthogonal projection of a point onto a nonempty affine subspace, whose direction is complete. The corresponding linear map (mapping a vector to the difference between the projections of two points whose difference is that vector) is the orthogonalProjection for real inner product spaces, onto the direction of the affine subspace being projected onto.

Equations
Instances For
@[simp]
theorem EuclideanGeometry.orthogonalProjectionFn_eq {V : Type u_1} {P : Type u_2} [] [] [] {s : } [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) :
@[simp]
theorem EuclideanGeometry.orthogonalProjection_linear {V : Type u_1} {P : Type u_2} [] [] [] {s : } [Nonempty s] [HasOrthogonalProjection s.direction] :
.linear = (orthogonalProjection s.direction)

The linear map corresponding to orthogonalProjection.

theorem EuclideanGeometry.inter_eq_singleton_orthogonalProjection {V : Type u_1} {P : Type u_2} [] [] [] {s : } [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) :
s (AffineSubspace.mk' p s.direction) = {}

The intersection of the subspace and the orthogonal subspace through the given point is the orthogonalProjection of that point onto the subspace.

theorem EuclideanGeometry.orthogonalProjection_mem {V : Type u_1} {P : Type u_2} [] [] [] {s : } [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) :
s

The orthogonalProjection lies in the given subspace.

theorem EuclideanGeometry.orthogonalProjection_mem_orthogonal {V : Type u_1} {P : Type u_2} [] [] [] (s : ) [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) :
AffineSubspace.mk' p s.direction

The orthogonalProjection lies in the orthogonal subspace.

theorem EuclideanGeometry.orthogonalProjection_vsub_mem_direction {V : Type u_1} {P : Type u_2} [] [] [] {s : } [Nonempty s] [HasOrthogonalProjection s.direction] {p1 : P} (p2 : P) (hp1 : p1 s) :
( -ᵥ p1, hp1) s.direction

Subtracting a point in the given subspace from the orthogonalProjection produces a result in the direction of the given subspace.

theorem EuclideanGeometry.vsub_orthogonalProjection_mem_direction {V : Type u_1} {P : Type u_2} [] [] [] {s : } [Nonempty s] [HasOrthogonalProjection s.direction] {p1 : P} (p2 : P) (hp1 : p1 s) :
(p1, hp1 -ᵥ ) s.direction

Subtracting the orthogonalProjection from a point in the given subspace produces a result in the direction of the given subspace.

theorem EuclideanGeometry.orthogonalProjection_eq_self_iff {V : Type u_1} {P : Type u_2} [] [] [] {s : } [Nonempty s] [HasOrthogonalProjection s.direction] {p : P} :
= p p s

A point equals its orthogonal projection if and only if it lies in the subspace.

@[simp]
theorem EuclideanGeometry.orthogonalProjection_mem_subspace_eq_self {V : Type u_1} {P : Type u_2} [] [] [] {s : } [Nonempty s] [HasOrthogonalProjection s.direction] (p : s) :
theorem EuclideanGeometry.orthogonalProjection_orthogonalProjection {V : Type u_1} {P : Type u_2} [] [] [] (s : ) [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) :

Orthogonal projection is idempotent.

theorem EuclideanGeometry.eq_orthogonalProjection_of_eq_subspace {V : Type u_1} {P : Type u_2} [] [] [] {s : } {s' : } [Nonempty s] [Nonempty s'] [HasOrthogonalProjection s.direction] [HasOrthogonalProjection s'.direction] (h : s = s') (p : P) :
theorem EuclideanGeometry.dist_orthogonalProjection_eq_zero_iff {V : Type u_1} {P : Type u_2} [] [] [] {s : } [Nonempty s] [HasOrthogonalProjection s.direction] {p : P} :
= 0 p s

The distance to a point's orthogonal projection is 0 iff it lies in the subspace.

theorem EuclideanGeometry.dist_orthogonalProjection_ne_zero_of_not_mem {V : Type u_1} {P : Type u_2} [] [] [] {s : } [Nonempty s] [HasOrthogonalProjection s.direction] {p : P} (hp : ps) :
0

The distance between a point and its orthogonal projection is nonzero if it does not lie in the subspace.

theorem EuclideanGeometry.orthogonalProjection_vsub_mem_direction_orthogonal {V : Type u_1} {P : Type u_2} [] [] [] (s : ) [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) :
-ᵥ p s.direction

Subtracting p from its orthogonalProjection produces a result in the orthogonal direction.

theorem EuclideanGeometry.vsub_orthogonalProjection_mem_direction_orthogonal {V : Type u_1} {P : Type u_2} [] [] [] (s : ) [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) :
p -ᵥ s.direction

Subtracting the orthogonalProjection from p produces a result in the orthogonal direction.

theorem EuclideanGeometry.orthogonalProjection_vsub_orthogonalProjection {V : Type u_1} {P : Type u_2} [] [] [] (s : ) [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) :
(orthogonalProjection s.direction) (p -ᵥ ) = 0

Subtracting the orthogonalProjection from p produces a result in the kernel of the linear part of the orthogonal projection.

theorem EuclideanGeometry.orthogonalProjection_vadd_eq_self {V : Type u_1} {P : Type u_2} [] [] [] {s : } [Nonempty s] [HasOrthogonalProjection s.direction] {p : P} (hp : p s) {v : V} (hv : v s.direction) :
(v +ᵥ p) = p, hp

Adding a vector to a point in the given subspace, then taking the orthogonal projection, produces the original point if the vector was in the orthogonal direction.

theorem EuclideanGeometry.orthogonalProjection_vadd_smul_vsub_orthogonalProjection {V : Type u_1} {P : Type u_2} [] [] [] {s : } [Nonempty s] [HasOrthogonalProjection s.direction] {p1 : P} (p2 : P) (r : ) (hp : p1 s) :
(r (p2 -ᵥ ) +ᵥ p1) = p1, hp

Adding a vector to a point in the given subspace, then taking the orthogonal projection, produces the original point if the vector is a multiple of the result of subtracting a point's orthogonal projection from that point.

theorem EuclideanGeometry.dist_sq_eq_dist_orthogonalProjection_sq_add_dist_orthogonalProjection_sq {V : Type u_1} {P : Type u_2} [] [] [] {s : } [Nonempty s] [HasOrthogonalProjection s.direction] {p1 : P} (p2 : P) (hp1 : p1 s) :
dist p1 p2 * dist p1 p2 = dist p1 * dist p1 + dist p2 * dist p2

The square of the distance from a point in s to p2 equals the sum of the squares of the distances of the two points to the orthogonalProjection.

theorem EuclideanGeometry.dist_sq_smul_orthogonal_vadd_smul_orthogonal_vadd {V : Type u_1} {P : Type u_2} [] [] [] {s : } {p1 : P} {p2 : P} (hp1 : p1 s) (hp2 : p2 s) (r1 : ) (r2 : ) {v : V} (hv : v s.direction) :
dist (r1 v +ᵥ p1) (r2 v +ᵥ p2) * dist (r1 v +ᵥ p1) (r2 v +ᵥ p2) = dist p1 p2 * dist p1 p2 + (r1 - r2) * (r1 - r2) * (v * v)

The square of the distance between two points constructed by adding multiples of the same orthogonal vector to points in the same subspace.

def EuclideanGeometry.reflection {V : Type u_1} {P : Type u_2} [] [] [] (s : ) [Nonempty s] [HasOrthogonalProjection s.direction] :

Reflection in an affine subspace, which is expected to be nonempty and complete. The word "reflection" is sometimes understood to mean specifically reflection in a codimension-one subspace, and sometimes more generally to cover operations such as reflection in a point. The definition here, of reflection in an affine subspace, is a more general sense of the word that includes both those common cases.

Equations
• One or more equations did not get rendered due to their size.
Instances For
theorem EuclideanGeometry.reflection_apply {V : Type u_1} {P : Type u_2} [] [] [] (s : ) [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) :
= -ᵥ p +ᵥ

The result of reflecting.

theorem EuclideanGeometry.eq_reflection_of_eq_subspace {V : Type u_1} {P : Type u_2} [] [] [] {s : } {s' : } [Nonempty s] [Nonempty s'] [HasOrthogonalProjection s.direction] [HasOrthogonalProjection s'.direction] (h : s = s') (p : P) :
@[simp]
theorem EuclideanGeometry.reflection_reflection {V : Type u_1} {P : Type u_2} [] [] [] (s : ) [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) :

Reflecting twice in the same subspace.

@[simp]
theorem EuclideanGeometry.reflection_symm {V : Type u_1} {P : Type u_2} [] [] [] (s : ) [Nonempty s] [HasOrthogonalProjection s.direction] :

Reflection is its own inverse.

theorem EuclideanGeometry.reflection_involutive {V : Type u_1} {P : Type u_2} [] [] [] (s : ) [Nonempty s] [HasOrthogonalProjection s.direction] :

Reflection is involutive.

theorem EuclideanGeometry.reflection_eq_self_iff {V : Type u_1} {P : Type u_2} [] [] [] {s : } [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) :
p s

A point is its own reflection if and only if it is in the subspace.

theorem EuclideanGeometry.reflection_eq_iff_orthogonalProjection_eq {V : Type u_1} {P : Type u_2} [] [] [] (s₁ : ) (s₂ : ) [Nonempty s₁] [Nonempty s₂] [HasOrthogonalProjection s₁.direction] [HasOrthogonalProjection s₂.direction] (p : P) :
=

Reflecting a point in two subspaces produces the same result if and only if the point has the same orthogonal projection in each of those subspaces.

theorem EuclideanGeometry.dist_reflection {V : Type u_1} {P : Type u_2} [] [] [] (s : ) [Nonempty s] [HasOrthogonalProjection s.direction] (p₁ : P) (p₂ : P) :
dist p₁ () = dist () p₂

The distance between p₁ and the reflection of p₂ equals that between the reflection of p₁ and p₂.

theorem EuclideanGeometry.dist_reflection_eq_of_mem {V : Type u_1} {P : Type u_2} [] [] [] (s : ) [Nonempty s] [HasOrthogonalProjection s.direction] {p₁ : P} (hp₁ : p₁ s) (p₂ : P) :
dist p₁ () = dist p₁ p₂

A point in the subspace is equidistant from another point and its reflection.

theorem EuclideanGeometry.reflection_mem_of_le_of_mem {V : Type u_1} {P : Type u_2} [] [] [] {s₁ : } {s₂ : } [Nonempty s₁] [HasOrthogonalProjection s₁.direction] (hle : s₁ s₂) {p : P} (hp : p s₂) :
s₂

The reflection of a point in a subspace is contained in any larger subspace containing both the point and the subspace reflected in.

theorem EuclideanGeometry.reflection_orthogonal_vadd {V : Type u_1} {P : Type u_2} [] [] [] {s : } [Nonempty s] [HasOrthogonalProjection s.direction] {p : P} (hp : p s) {v : V} (hv : v s.direction) :
(v +ᵥ p) = -v +ᵥ p

Reflecting an orthogonal vector plus a point in the subspace produces the negation of that vector plus the point.

theorem EuclideanGeometry.reflection_vadd_smul_vsub_orthogonalProjection {V : Type u_1} {P : Type u_2} [] [] [] {s : } [Nonempty s] [HasOrthogonalProjection s.direction] {p₁ : P} (p₂ : P) (r : ) (hp₁ : p₁ s) :
(r (p₂ -ᵥ ) +ᵥ p₁) = -(r (p₂ -ᵥ )) +ᵥ p₁

Reflecting a vector plus a point in the subspace produces the negation of that vector plus the point if the vector is a multiple of the result of subtracting a point's orthogonal projection from that point.