Skip to content

Commit 2d3126e

Browse files
committed
Correct Proj4 to Proj3
The correct name for a projective space over R^4 is P_3(R).
1 parent cc549cd commit 2d3126e

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

core/src/math/mat.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use crate::render::{NdcToScreen, ViewToProj};
1616
use super::{
1717
float::f32,
1818
point::{Point2, Point2u, Point3},
19-
space::{Linear, Proj4, Real},
20-
vec::{ProjVec4, Vec2, Vec3, Vector},
19+
space::{Linear, Proj3, Real},
20+
vec::{ProjVec3, Vec2, Vec3, Vector},
2121
};
2222

2323
/// A linear transform from one space (or basis) to another.
@@ -401,7 +401,7 @@ impl<Src> Mat4x4<RealToProj<Src>> {
401401
/// \ · · M33 / \ 1 / \ v3' /
402402
/// ```
403403
#[must_use]
404-
pub fn apply(&self, p: &Point3<Src>) -> ProjVec4 {
404+
pub fn apply(&self, p: &Point3<Src>) -> ProjVec3 {
405405
let v = Vector::new([p.x(), p.y(), p.z(), 1.0]);
406406
from_fn(|i| self.row_vec(i).dot(&v)).into()
407407
}
@@ -424,7 +424,7 @@ impl<const DIM: usize, S, I, D> Compose<RealToReal<DIM, S, I>>
424424

425425
impl<S> LinearMap for RealToProj<S> {
426426
type Source = Real<3, S>;
427-
type Dest = Proj4;
427+
type Dest = Proj3;
428428
}
429429

430430
impl<S, I> Compose<RealToReal<3, S, I>> for RealToProj<I> {

core/src/math/space.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ pub trait Linear: Affine<Diff = Self> {
7474
#[derive(Copy, Clone, Default, Eq, PartialEq)]
7575
pub struct Real<const DIM: usize, Basis = ()>(PhantomData<Basis>);
7676

77-
/// Tag type for the projective 4-space over reals, 𝗣<sub>4</sub>(ℝ).
77+
/// Tag type for the projective 3-space over the reals, 𝗣<sub>3</sub>(ℝ).
7878
///
7979
/// The properties of this space make it useful for implementing perspective
8080
/// projection. Clipping is also done in the projective space.
8181
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
82-
pub struct Proj4;
82+
pub struct Proj3;
8383

8484
impl Affine for f32 {
8585
type Space = ();

core/src/math/vec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use core::{
1414
use crate::math::{
1515
Affine, ApproxEq, Linear, Point,
1616
float::f32,
17-
space::{Proj4, Real},
17+
space::{Proj3, Real},
1818
vary::ZDiv,
1919
};
2020

@@ -42,7 +42,7 @@ pub type Vec2<Basis = ()> = Vector<[f32; 2], Real<2, Basis>>;
4242
/// A 3-vector with `f32` components.
4343
pub type Vec3<Basis = ()> = Vector<[f32; 3], Real<3, Basis>>;
4444
/// A `f32` 4-vector in the projective 3-space over ℝ, aka P<sub>3</sub>(ℝ).
45-
pub type ProjVec4 = Vector<[f32; 4], Proj4>;
45+
pub type ProjVec3 = Vector<[f32; 4], Proj3>;
4646

4747
/// A 2-vector with `i32` components.
4848
pub type Vec2i<Basis = ()> = Vector<[i32; 2], Real<2, Basis>>;
@@ -366,7 +366,7 @@ impl<B> Vec3<B> {
366366
pub const Z: Self = vec3(0.0, 0.0, 1.0);
367367
}
368368

369-
impl<R, Sc> Vector<R, Proj4>
369+
impl<R, Sc> Vector<R, Proj3>
370370
where
371371
R: Index<usize, Output = Sc>,
372372
Sc: Copy,

core/src/render.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::geom::Vertex;
1212
use crate::math::{
1313
Lerp, Mat4x4, Vary,
1414
mat::{RealToProj, RealToReal},
15-
vec::ProjVec4,
15+
vec::ProjVec3,
1616
};
1717

1818
use {
@@ -116,11 +116,11 @@ pub type NdcToScreen = RealToReal<3, Ndc, Screen>;
116116

117117
/// Alias for combined vertex+fragment shader types
118118
pub trait Shader<Vtx, Var, Uni>:
119-
VertexShader<Vtx, Uni, Output = Vertex<ProjVec4, Var>> + FragmentShader<Var>
119+
VertexShader<Vtx, Uni, Output = Vertex<ProjVec3, Var>> + FragmentShader<Var>
120120
{
121121
}
122122
impl<S, Vtx, Var, Uni> Shader<Vtx, Var, Uni> for S where
123-
S: VertexShader<Vtx, Uni, Output = Vertex<ProjVec4, Var>>
123+
S: VertexShader<Vtx, Uni, Output = Vertex<ProjVec3, Var>>
124124
+ FragmentShader<Var>
125125
{
126126
}

core/src/render/clip.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use core::iter::zip;
1919
use view_frustum::{outcode, status};
2020

2121
use crate::geom::{Tri, Vertex, vertex};
22-
use crate::math::{Lerp, vec::ProjVec4};
22+
use crate::math::{Lerp, vec::ProjVec3};
2323

2424
/// Trait for types that can be [clipped][self] against planes.
2525
///
@@ -50,7 +50,7 @@ pub trait Clip {
5050
}
5151

5252
/// A vector in clip space.
53-
pub type ClipVec = ProjVec4;
53+
pub type ClipVec = ProjVec3;
5454

5555
/// A vertex in clip space.
5656
#[derive(Copy, Clone, Debug, PartialEq)]

core/src/render/shader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
1717
use crate::{
1818
geom::Vertex,
19-
math::{Color4, vec::ProjVec4},
19+
math::{Color4, vec::ProjVec3},
2020
};
2121

2222
use super::raster::Frag;
@@ -77,7 +77,7 @@ where
7777

7878
pub fn new<Vs, Fs, Vtx, Var, Uni>(vs: Vs, fs: Fs) -> Shader<Vs, Fs>
7979
where
80-
Vs: VertexShader<Vtx, Uni, Output = Vertex<ProjVec4, Var>>,
80+
Vs: VertexShader<Vtx, Uni, Output = Vertex<ProjVec3, Var>>,
8181
Fs: FragmentShader<Var>,
8282
{
8383
Shader::new(vs, fs)

demos/src/bin/solids.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use re::prelude::*;
66

77
use re::geom::Polyline;
88
use re::math::{
9-
color::gray, mat::RealToReal, pt2, smootherstep, vec::ProjVec4,
9+
color::gray, mat::RealToReal, pt2, smootherstep, vec::ProjVec3,
1010
};
1111
use re::render::{
1212
Batch, Camera, ModelToProj, ModelToWorld, cam::Fov, raster::Frag,
@@ -66,7 +66,7 @@ fn main() {
6666
.viewport(pt2(10, 10)..pt2(w - 10, h - 10));
6767

6868
type VertexIn = Vertex3<Normal3>;
69-
type VertexOut = Vertex<ProjVec4, Color3f>;
69+
type VertexOut = Vertex<ProjVec3, Color3f>;
7070
type Uniform<'a> = (&'a Mat4x4<ModelToProj>, &'a Mat4x4<RealToReal<3>>);
7171

7272
fn vtx_shader(v: VertexIn, (mvp, spin): Uniform) -> VertexOut {

0 commit comments

Comments
 (0)