reckfellENGINE

Projection

A 4×4 projective-transformation matrix with four Vector4 columns.

On this page
struct ProjectionReckfellSharpInherits ValueType

A C# struct representing a 4×4 matrix with four Vector4 columns: X, Y, Z and W. Used for projective transformations and camera projection. Assignment copies the matrix value.

Projection.Identity is the identity matrix; default(Projection) has zero coefficients and is not Identity. Neither value is true or false in C#: Projection has no conversion to bool. An explicit Identity comparison tests coefficients, not suitability for a particular camera.

Choose a projection constructor for the task and respect its near/far, angle and size restrictions. Transform3D describes an ordinary object position/rotation/scale transform; it is not automatically a suitable camera projection.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors3

Projection3 overloads
# Projection · 1/3
C#
public Projection(Transform3D transform);

Constructs a Projection from four Vector4 values (matrix columns).

Parameters
NameTypeDefault
transformTransform3D—
transform

The Transform3D.

# Projection · 2/3
C#
public Projection(Vector4 x, Vector4 y, Vector4 z, Vector4 w);

Constructs a Projection from four Vector4 values (matrix columns).

Parameters
NameTypeDefault
xVector4—
yVector4—
zVector4—
wVector4—
x

The X column, or column index 0.

y

The Y column, or column index 1.

z

The Z column, or column index 2.

w

The W column, or column index 3.

# Projection · 3/3
C#
public Projection(float xx, float xy, float xz, float xw, float yx, float yy, float yz, float yw, float zx, float zy, float zz, float zw, float wx, float wy, float wz, float ww);

Constructs a Projection from four Vector4 values (matrix columns).

Parameters
NameTypeDefault
xxfloat—
xyfloat—
xzfloat—
xwfloat—
yxfloat—
yyfloat—
yzfloat—
ywfloat—
zxfloat—
zyfloat—
zzfloat—
zwfloat—
wxfloat—
wyfloat—
wzfloat—
wwfloat—
xx

The X column vector's X component, accessed via p.X.X or [0][0].

xy

The X column vector's Y component, accessed via p.X.Y or [0][1].

xz

The X column vector's Z component, accessed via p.X.Z or [0][2].

xw

The X column vector's W component, accessed via p.X.W or [0][3].

yx

The Y column vector's X component, accessed via p.Y.X or [1][0].

yy

The Y column vector's Y component, accessed via p.Y.Y or [1][1].

yz

The Y column vector's Z component, accessed via p.Y.Z or [1][2].

yw

The Y column vector's W component, accessed via p.Y.W or [1][3].

zx

The Z column vector's X component, accessed via p.Z.X or [2][0].

zy

The Z column vector's Y component, accessed via p.Z.Y or [2][1].

zz

The Z column vector's Z component, accessed via p.Z.Z or [2][2].

zw

The Z column vector's W component, accessed via p.Z.W or [2][3].

wx

The W column vector's X component, accessed via p.W.X or [3][0].

wy

The W column vector's Y component, accessed via p.W.Y or [3][1].

wz

The W column vector's Z component, accessed via p.W.Z or [3][2].

ww

The W column vector's W component, accessed via p.W.W or [3][3].

Properties4

IdentityProperty
# Identity
C#
public static Projection Identity { get; }

A Projection with no transformation defined. When applied to other data structures, no transformation is performed.

Item2 overloads
# Item · 1/2
C#
public Vector4 this[int column] { get; set; }

Access whole columns in the form of Vector4.

# Item · 2/2
C#
public float this[int column, int row] { get; set; }

Access single values.

ZeroProperty
# Zero
C#
public static Projection Zero { get; }

A Projection with all values initialized to 0. When applied to other data structures, they will be zeroed.

Methods38

CreateDepthCorrectionProjection
# CreateDepthCorrection
C#
public static Projection CreateDepthCorrection(bool flipY);

Creates a new Projection that projects positions from a depth range of -1 to 1 to one that ranges from 0 to 1, and flips the projected positions vertically, according to flip_y.

Parameters
NameTypeDefault
flipYbool—
flipY

If the projection should be flipped vertically.

Returns Projection

The created projection.

CreateFitAabbProjection
# CreateFitAabb
C#
public static Projection CreateFitAabb(Aabb aabb);

Creates a new Projection that scales a given projection to fit around a given Aabb in projection space.

Parameters
NameTypeDefault
aabbAabb—
aabb

The Aabb to fit the projection around.

Returns Projection

The created projection.

CreateForHmdProjection
# CreateForHmd
C#
public static Projection CreateForHmd(int eye, float aspect, float intraocularDist, float displayWidth, float displayToLens, float oversample, float zNear, float zFar);

Creates a new Projection for projecting positions onto a head-mounted display with the given X:Y aspect ratio, distance between eyes, display width, distance to lens, oversampling factor, and depth clipping planes. eye creates the projection for the left eye when set to 1, or the right eye when set to 2.

Parameters
NameTypeDefault
eyeint—
aspectfloat—
intraocularDistfloat—
displayWidthfloat—
displayToLensfloat—
oversamplefloat—
zNearfloat—
zFarfloat—
eye

The eye to create the projection for. The left eye when set to 1, the right eye when set to 2.

aspect

The aspect ratio.

intraocularDist

The distance between the eyes.

displayWidth

The display width.

displayToLens

The distance to the lens.

oversample

The oversampling factor.

zNear

The near clipping distance.

zFar

The far clipping distance.

Returns Projection

The created projection.

CreateFrustumProjection
# CreateFrustum
C#
public static Projection CreateFrustum(float left, float right, float bottom, float top, float depthNear, float depthFar);

Creates a new Projection that projects positions in a frustum with the given clipping planes.

Parameters
NameTypeDefault
leftfloat—
rightfloat—
bottomfloat—
topfloat—
depthNearfloat—
depthFarfloat—
left

The left clipping distance.

right

The right clipping distance.

bottom

The bottom clipping distance.

top

The top clipping distance.

depthNear

The near clipping distance.

depthFar

The far clipping distance.

Returns Projection

The created projection.

CreateFrustumAspectProjection
# CreateFrustumAspect
C#
public static Projection CreateFrustumAspect(float size, float aspect, Vector2 offset, float depthNear, float depthFar, bool flipFov);

Creates a new Projection that projects positions in a frustum with the given size, X:Y aspect ratio, offset, and clipping planes. flip_fov determines whether the projection's field of view is flipped over its diagonal.

Parameters
NameTypeDefault
sizefloat—
aspectfloat—
offsetVector2—
depthNearfloat—
depthFarfloat—
flipFovbool—
size

The frustum size.

aspect

The aspect ratio.

offset

The offset to apply.

depthNear

The near clipping distance.

depthFar

The far clipping distance.

flipFov

If the field of view is flipped over the projection's diagonal.

Returns Projection

The created projection.

CreateLightAtlasRectProjection
# CreateLightAtlasRect
C#
public static Projection CreateLightAtlasRect(Rect2 rect);

Creates a new Projection that projects positions into the given Rect2.

Parameters
NameTypeDefault
rectRect2—
rect

The Rect2 to project positions into.

Returns Projection

The created projection.

CreateOrthogonalProjection
# CreateOrthogonal
C#
public static Projection CreateOrthogonal(float left, float right, float bottom, float top, float zNear, float zFar);

Creates a new Projection that projects positions using an orthogonal projection with the given clipping planes.

Parameters
NameTypeDefault
leftfloat—
rightfloat—
bottomfloat—
topfloat—
zNearfloat—
zFarfloat—
left

The left clipping distance.

right

The right clipping distance.

bottom

The bottom clipping distance.

top

The top clipping distance.

zNear

The near clipping distance.

zFar

The far clipping distance.

Returns Projection

The created projection.

CreateOrthogonalAspectProjection
# CreateOrthogonalAspect
C#
public static Projection CreateOrthogonalAspect(float size, float aspect, float zNear, float zFar, bool flipFov);

Creates a new Projection that projects positions using an orthogonal projection with the given size, X:Y aspect ratio, and clipping planes. flip_fov determines whether the projection's field of view is flipped over its diagonal.

Parameters
NameTypeDefault
sizefloat—
aspectfloat—
zNearfloat—
zFarfloat—
flipFovbool—
size

The frustum size.

aspect

The aspect ratio.

zNear

The near clipping distance.

zFar

The far clipping distance.

flipFov

If the field of view is flipped over the projection's diagonal.

Returns Projection

The created projection.

CreatePerspectiveProjection
# CreatePerspective
C#
public static Projection CreatePerspective(float fovyDegrees, float aspect, float zNear, float zFar, bool flipFov);

Creates a new Projection that projects positions using a perspective projection with the given Y-axis field of view (in degrees), X:Y aspect ratio, and clipping planes. flip_fov determines whether the projection's field of view is flipped over its diagonal.

Parameters
NameTypeDefault
fovyDegreesfloat—
aspectfloat—
zNearfloat—
zFarfloat—
flipFovbool—
fovyDegrees

The vertical field of view (in degrees).

aspect

The aspect ratio.

zNear

The near clipping distance.

zFar

The far clipping distance.

flipFov

If the field of view is flipped over the projection's diagonal.

Returns Projection

The created projection.

CreatePerspectiveHmdProjection
# CreatePerspectiveHmd
C#
public static Projection CreatePerspectiveHmd(float fovyDegrees, float aspect, float zNear, float zFar, bool flipFov, int eye, float intraocularDist, float convergenceDist);

Creates a new Projection that projects positions using a perspective projection with the given Y-axis field of view (in degrees), X:Y aspect ratio, and clipping distances. The projection is adjusted for a head-mounted display with the given distance between eyes and distance to a point that can be focused on. eye creates the projection for the left eye when set to 1, or the right eye when set to 2. flip_fov determines whether the projection's field of view is flipped over its diagonal.

Parameters
NameTypeDefault
fovyDegreesfloat—
aspectfloat—
zNearfloat—
zFarfloat—
flipFovbool—
eyeint—
intraocularDistfloat—
convergenceDistfloat—
fovyDegrees

The vertical field of view (in degrees).

aspect

The aspect ratio.

zNear

The near clipping distance.

zFar

The far clipping distance.

flipFov

If the field of view is flipped over the projection's diagonal.

eye

The eye to create the projection for. The left eye when set to 1, the right eye when set to 2.

intraocularDist

The distance between the eyes.

convergenceDist

The distance to a point of convergence that can be focused on.

Returns Projection

The created projection.

Determinantfloat
# Determinant
C#
public float Determinant();

Returns a scalar value that is the signed factor by which areas are scaled by this matrix. If the sign is negative, the matrix flips the orientation of the area. The determinant can be used to calculate the invertibility of a matrix or solve linear systems of equations involving the matrix, among other applications.

Returns float

The determinant calculated from this projection.

Equals2 overloads
# Equals · 1/2
C#
public bool Equals(Projection other);

Returns true if the projections are exactly equal.

Parameters
NameTypeDefault
otherProjection—
other

The other projection.

Returns bool

Whether or not the projections are exactly equal.

# Equals · 2/2
C#
public override bool Equals(object? obj);

Returns true if the projection is exactly equal to the given object (obj).

Parameters
NameTypeDefault
objobject—
obj

The object to compare with.

Returns bool

Whether or not the vector and the object are equal.

FlippedYProjection
# FlippedY
C#
public Projection FlippedY();

Returns a copy of this Projection with the signs of the values of the Y column flipped.

Returns Projection

The flipped projection.

GetAspectfloat
# GetAspect
C#
public float GetAspect();

Returns the X:Y aspect ratio of this Projection's viewport.

Returns float

The aspect ratio from this projection's viewport.

GetFarPlaneHalfExtentsVector2
# GetFarPlaneHalfExtents
C#
public Vector2 GetFarPlaneHalfExtents();

Returns the dimensions of the far clipping plane of the projection, divided by two.

Returns Vector2

The half extents for this projection's far plane.

GetFovfloat
# GetFov
C#
public float GetFov();

Returns the horizontal field of view of the projection (in degrees).

Returns float

The horizontal field of view of this projection.

GetFovyfloat
# GetFovy
C#
public static float GetFovy(float fovx, float aspect);

Returns the vertical field of view of the projection (in degrees) associated with the given horizontal field of view (in degrees) and aspect ratio. Note: Unlike most methods of Projection, aspect is expected to be 1 divided by the X:Y aspect ratio.

Parameters
NameTypeDefault
fovxfloat—
aspectfloat—
fovx

The horizontal field of view (in degrees).

aspect

The aspect ratio.

Returns float

The vertical field of view of this projection.

GetHashCodeint
# GetHashCode
C#
public override int GetHashCode();

Serves as the hash function for Projection.

Returns int

A hash code for this projection.

GetLodMultiplierfloat
# GetLodMultiplier
C#
public float GetLodMultiplier();

Returns the factor by which the visible level of detail is scaled by this Projection.

Returns float

The level of detail factor for this projection.

GetPixelsPerMeterint
# GetPixelsPerMeter
C#
public int GetPixelsPerMeter(int forPixelWidth);

Returns for_pixel_width divided by the viewport's width measured in meters on the near plane, after this Projection is applied.

Parameters
NameTypeDefault
forPixelWidthint—
forPixelWidth

The width for each pixel (in meters).

Returns int

The number of pixels per meter.

GetProjectionPlanePlane
# GetProjectionPlane
C#
public Plane GetProjectionPlane(Projection.Planes plane);

Returns the clipping plane of this Projection whose index is given by plane. plane should be equal to one of Projection.Planes.Near, Projection.Planes.Far, Projection.Planes.Left, Projection.Planes.Top, Projection.Planes.Right, or Projection.Planes.Bottom.

Parameters
NameTypeDefault
planeProjection.Planes—
plane

The kind of clipping plane to get from the projection.

Returns Plane

The clipping plane of this projection.

GetViewportHalfExtentsVector2
# GetViewportHalfExtents
C#
public Vector2 GetViewportHalfExtents();

Returns the dimensions of the viewport plane that this Projection projects positions onto, divided by two.

Returns Vector2

The half extents for this projection's viewport plane.

GetZFarfloat
# GetZFar
C#
public float GetZFar();

Returns the distance for this Projection beyond which positions are clipped.

Returns float

The distance beyond which positions are clipped.

GetZNearfloat
# GetZNear
C#
public float GetZNear();

Returns the distance for this Projection before which positions are clipped.

Returns float

The distance before which positions are clipped.

InverseProjection
# Inverse
C#
public Projection Inverse();

Returns a Projection that performs the inverse of this Projection's projective transformation.

Returns Projection

The inverted projection.

IsOrthogonalbool
# IsOrthogonal
C#
public bool IsOrthogonal();

Returns true if this Projection performs an orthogonal projection.

Returns bool

If the projection performs an orthogonal projection.

JitterOffsetedProjection
# JitterOffseted
C#
public Projection JitterOffseted(Vector2 offset);

Returns a Projection with the X and Y values from the given Vector2 added to the first and second values of the final column respectively.

Parameters
NameTypeDefault
offsetVector2—
offset

The offset to apply to the projection.

Returns Projection

The offsetted projection.

PerspectiveZNearAdjustedProjection
# PerspectiveZNearAdjusted
C#
public Projection PerspectiveZNearAdjusted(float newZNear);

Returns a Projection with the near clipping distance adjusted to be new_znear. Note: The original Projection must be a perspective projection.

Parameters
NameTypeDefault
newZNearfloat—
newZNear

The near clipping distance to adjust the projection to.

Returns Projection

The adjusted projection.

ToString2 overloads
# ToString · 1/2
C#
public override string ToString();

Converts this Projection to a string.

Returns string

A string representation of this projection.

# ToString · 2/2
C#
public string ToString(string? format);

Converts this Projection to a string with the given format.

Parameters
NameTypeDefault
formatstring—
Returns string

A string representation of this projection.

op_Equalitybool
# op_Equality
C#
public static bool operator ==(Projection left, Projection right);

Returns true if the projections are exactly equal.

Parameters
NameTypeDefault
leftProjection—
rightProjection—
left

The left projection.

right

The right projection.

Returns bool

Whether or not the projections are exactly equal.

op_ExplicitTransform3D
# op_Explicit
C#
public static explicit operator Transform3D(Projection proj);

Constructs a new Transform3D from the Projection.

Parameters
NameTypeDefault
projProjection—
proj

The Projection.

Returns Transform3D
op_Inequalitybool
# op_Inequality
C#
public static bool operator !=(Projection left, Projection right);

Returns true if the projections are not exactly equal.

Parameters
NameTypeDefault
leftProjection—
rightProjection—
left

The left projection.

right

The right projection.

Returns bool

Whether or not the projections are not exactly equal.

op_Multiply4 overloads
# op_Multiply · 1/4
C#
public static Projection operator *(Projection left, Projection right);

Composes these two projections by multiplying them together. This has the effect of applying the right and then the left projection.

Parameters
NameTypeDefault
leftProjection—
rightProjection—
left

The parent transform.

right

The child transform.

Returns Projection

The composed projection.

# op_Multiply · 2/4
C#
public static Vector3 operator *(Projection proj, Vector3 vector);

Returns a Vector3 transformed (multiplied) by the projection.

Parameters
NameTypeDefault
projProjection—
vectorVector3—
proj

The projection to apply.

vector

A Vector3 to transform.

Returns Vector3

The transformed Vector3.

# op_Multiply · 3/4
C#
public static Vector4 operator *(Projection proj, Vector4 vector);

Returns a Vector4 transformed (multiplied) by the projection.

Parameters
NameTypeDefault
projProjection—
vectorVector4—
proj

The projection to apply.

vector

A Vector4 to transform.

Returns Vector4

The transformed Vector4.

# op_Multiply · 4/4
C#
public static Vector4 operator *(Vector4 vector, Projection proj);

Returns a Vector4 transformed (multiplied) by the transpose of the projection. For transforming by inverse of a projection projection.Inverse() * vector can be used instead. See Projection.Inverse.

Parameters
NameTypeDefault
vectorVector4—
projProjection—
vector

A Vector4 to transform.

proj

The projection to apply.

Returns Vector4

The inversely transformed Vector4.

Fields and constants4

WField
# W
C#
public Vector4 W;

The projection matrix's W vector (column 3). Equivalent to array index 3.

XField
# X
C#
public Vector4 X;

The projection matrix's X vector (column 0). Equivalent to array index 0.

YField
# Y
C#
public Vector4 Y;

The projection matrix's Y vector (column 1). Equivalent to array index 1.

ZField
# Z
C#
public Vector4 Z;

The projection matrix's Z vector (column 2). Equivalent to array index 2.

Projection.Planes

ValueDescription
Bottom = 5

The index value of the projection bottom clipping plane.

Far = 1

The index value of the projection's far clipping plane.

Left = 2

The index value of the projection's left clipping plane.

Near = 0

The index value of the projection's near clipping plane.

Right = 4

The index value of the projection's right clipping plane.

Top = 3

The index value of the projection's top clipping plane.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.