> Agent-readable docs index: /llms.txt. Download /docs.zip to grep all markdown files locally.

---
title: Projection
icon: scan
---

# <ApiPageIcon icon="scan" />Projection

<ApiExposes data="[{&#x22;k&#x22;:&#x22;NAMESPACE&#x22;,&#x22;c&#x22;:&#x22;fn&#x22;,&#x22;s&#x22;:&#x22;projection&#x22;,&#x22;h&#x22;:&#x22;#projection-1&#x22;},{&#x22;k&#x22;:&#x22;CDATA&#x22;,&#x22;c&#x22;:&#x22;method&#x22;,&#x22;s&#x22;:&#x22;ProjectionRect&#x22;,&#x22;h&#x22;:&#x22;#projectionrect&#x22;},{&#x22;k&#x22;:&#x22;CDATA&#x22;,&#x22;c&#x22;:&#x22;method&#x22;,&#x22;s&#x22;:&#x22;ProjectionEllipse&#x22;,&#x22;h&#x22;:&#x22;#projectionellipse&#x22;},{&#x22;k&#x22;:&#x22;CTYPE&#x22;,&#x22;c&#x22;:&#x22;ctor&#x22;,&#x22;s&#x22;:&#x22;projection.Rect&#x22;,&#x22;h&#x22;:&#x22;#projectionrect-1&#x22;},{&#x22;k&#x22;:&#x22;CTYPE&#x22;,&#x22;c&#x22;:&#x22;ctor&#x22;,&#x22;s&#x22;:&#x22;projection.Ellipse&#x22;,&#x22;h&#x22;:&#x22;#projectionellipse-1&#x22;}]" />

<Heading level={2} id="projection-1">
  projection

  <ApiTag label="global table" />
</Heading>

Converts positions in the world to positions on the screen. The functions use the current
projection of the engine and the current render size.

Pixel coordinates start at the top left corner of the screen, and y increases downward. The
functions that take world positions use the first split screen slot, which is slot `0`.

All functions except `Matrix` return new values that you can keep and change. If a function
can return **nil**, it returns **nil** when the engine data that it needs is not available.

Call these functions from a render callback, when the render size is valid. Functions that take
world positions also need an active camera.

<ApiMembers>
  <ApiMember kind="prop" name="projection.Ellipse" ret="[[{&#x22;s&#x22;:&#x22;projection.Ellipse.namespace&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionellipse-1&#x22;}]]" />

  <ApiMember kind="prop" name="projection.Rect" ret="[[{&#x22;s&#x22;:&#x22;projection.Rect.namespace&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionrect-1&#x22;}]]" />

  <ApiMember kind="fn" name="projection.Matrix" summary="Returns a reference to the projection matrix of the engine for a split screen slot. You can change the matrix through the reference. When the engine updates the matrix, the values that you read change too. Throws an error if the slot is out of range. Returns **nil** if the projection matrices are not available." args="slot?" sig="[{&#x22;s&#x22;:&#x22;projection.Matrix&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;[&#x22;},{&#x22;s&#x22;:&#x22;slot&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;VMatrix&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vmatrix#vmatrix&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;VMatrix&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vmatrix#vmatrix&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;slot&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}],&#x22;d&#x22;:&#x22;An integer from `0` to `3`. The default is `0`.&#x22;,&#x22;o&#x22;:true}]" nodiscard>
    <ApiNotes>
      <Warning>
        If you write to the reference, you change the projection matrix of the engine, and this changes
        the rendering. Use the reference only while the engine memory is valid. Use `VMatrix(matrix)`
        to make a separate copy.
      </Warning>
    </ApiNotes>
  </ApiMember>

  <ApiMember kind="fn" name="projection.WorldToClip" summary="Converts a world position to homogeneous clip coordinates. The result is not divided by w." args="pos" sig="[{&#x22;s&#x22;:&#x22;projection.WorldToClip&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;pos&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector4D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector4d#vector4d&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;Vector4D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector4d#vector4d&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;pos&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;}],&#x22;d&#x22;:&#x22;The position in the world.&#x22;}]" nodiscard />

  <ApiMember kind="fn" name="projection.ClipToScreen" summary="Converts homogeneous clip coordinates to pixels. x and y are divided by w. If w is less than `0.0001`, `0.0001` is used in its place." args="clip" sig="[{&#x22;s&#x22;:&#x22;projection.ClipToScreen&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;clip&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector4D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector4d#vector4d&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;clip&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Vector4D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector4d#vector4d&#x22;}],&#x22;d&#x22;:&#x22;The homogeneous clip coordinates.&#x22;}]" nodiscard>
    <ApiNotes>
      z is ignored. Points outside the viewport and points with a w of zero or less are also
      converted. This function uses only the current render size. It returns **nil** only if the
      render size is not available.
    </ApiNotes>
  </ApiMember>

  <ApiMember kind="fn" name="projection.WorldToScreen" summary="Converts a world position to pixels. Returns **nil** if clip w is `0.0001` or less." args="pos" sig="[{&#x22;s&#x22;:&#x22;projection.WorldToScreen&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;pos&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;pos&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;}],&#x22;d&#x22;:&#x22;The position in the world.&#x22;}]" nodiscard>
    <ApiNotes>
      Points outside the viewport are also converted, and clip z is not checked. To find out whether
      the point is on the screen, compare the result with `engine.GetScreenSize`.
    </ApiNotes>
  </ApiMember>

  <ApiMember kind="fn" name="projection.WorldToScreenRounded" summary="The same as `WorldToScreen`, but each pixel coordinate is rounded down. Negative values are also rounded down." args="pos" sig="[{&#x22;s&#x22;:&#x22;projection.WorldToScreenRounded&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;pos&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;pos&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;}],&#x22;d&#x22;:&#x22;The position in the world.&#x22;}]" nodiscard />

  <ApiMember kind="fn" name="projection.Ellipsoid" summary="Returns the bounds on the screen of the outline of an ellipsoid. The axes of the ellipsoid are aligned with the axes of the world." args="center, radii" sig="[{&#x22;s&#x22;:&#x22;projection.Ellipsoid&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;center&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;radii&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ProjectionRect&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionrect&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;ProjectionRect&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionrect&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;center&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;}],&#x22;d&#x22;:&#x22;The center in world space.&#x22;},{&#x22;n&#x22;:&#x22;radii&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;}],&#x22;d&#x22;:&#x22;The radii in world space along the x, y and z axes.&#x22;}]" nodiscard>
    <ApiNotes>
      Returns **nil** if the outline is not finite or is not in front of the camera. This includes
      shapes that cross the plane of the camera. The bounds can go past the edges of the viewport.
    </ApiNotes>
  </ApiMember>

  <ApiMember kind="fn" name="projection.EllipsoidClipped" summary="The same as `Ellipsoid`, with one difference. If the outline is not finite or is not in front of the camera, this function returns the bounds of the part of the ellipsoid where clip w is greater than `0.0001`. It returns **nil** only if no such part exists. The bounds are not limited to the viewport." args="center, radii" sig="[{&#x22;s&#x22;:&#x22;projection.EllipsoidClipped&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;center&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;radii&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ProjectionRect&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionrect&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;ProjectionRect&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionrect&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;center&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;}],&#x22;d&#x22;:&#x22;The center in world space.&#x22;},{&#x22;n&#x22;:&#x22;radii&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;}],&#x22;d&#x22;:&#x22;The radii in world space along the x, y and z axes.&#x22;}]" nodiscard />

  <ApiMember kind="fn" name="projection.Sphere" summary="The same as `Ellipsoid`, with the same radius on all three world axes." args="center, radius" sig="[{&#x22;s&#x22;:&#x22;projection.Sphere&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;center&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;radius&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ProjectionRect&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionrect&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;ProjectionRect&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionrect&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;center&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;}],&#x22;d&#x22;:&#x22;The center in world space.&#x22;},{&#x22;n&#x22;:&#x22;radius&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;}],&#x22;d&#x22;:&#x22;The radius in world space.&#x22;}]" nodiscard />

  <ApiMember kind="fn" name="projection.EllipsoidEllipse" summary="Returns the full ellipse that an ellipsoid makes on the screen. The axes of the ellipsoid are aligned with the axes of the world. This function returns **nil** in the same cases as `Ellipsoid`. Because of perspective, the center of the ellipse can be at a different place from `WorldToScreen(center)`." args="center, radii" sig="[{&#x22;s&#x22;:&#x22;projection.EllipsoidEllipse&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;center&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;radii&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ProjectionEllipse&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionellipse&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;ProjectionEllipse&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionellipse&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;center&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;}],&#x22;d&#x22;:&#x22;The center in world space.&#x22;},{&#x22;n&#x22;:&#x22;radii&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;}],&#x22;d&#x22;:&#x22;The radii in world space along the x, y and z axes.&#x22;}]" nodiscard />

  <ApiMember kind="fn" name="projection.SphereEllipse" summary="The same as `EllipsoidEllipse`, with the same radius on all three world axes." args="center, radius" sig="[{&#x22;s&#x22;:&#x22;projection.SphereEllipse&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;center&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;radius&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ProjectionEllipse&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionellipse&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;ProjectionEllipse&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionellipse&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;center&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;}],&#x22;d&#x22;:&#x22;The center in world space.&#x22;},{&#x22;n&#x22;:&#x22;radius&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;}],&#x22;d&#x22;:&#x22;The radius in world space.&#x22;}]" nodiscard />

  <ApiMember kind="fn" name="projection.Camera" summary="Returns the position and orientation of the camera, calculated from the current projection matrix. The returned transform has a scale of `1`. Returns **nil** if the length of a camera axis in the matrix is `0.0001` or less." args="" sig="[{&#x22;s&#x22;:&#x22;projection.Camera&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;CTransform&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/transform#ctransform&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;CTransform&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/transform#ctransform&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" nodiscard />

  <ApiMember kind="fn" name="projection.ClipLineToScreen" summary="Cuts a line segment in world space to the part where clip z is `0` or greater. Then converts its end points to pixels and returns them in their original order. Returns **nil** if clip z is negative at both end points." args="start, finish" sig="[{&#x22;s&#x22;:&#x22;projection.ClipLineToScreen&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;start&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;finish&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}],[{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;start&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;}],&#x22;d&#x22;:&#x22;The start of the line in world space.&#x22;},{&#x22;n&#x22;:&#x22;finish&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;}],&#x22;d&#x22;:&#x22;The end of the line in world space.&#x22;}]" returns="[{&#x22;n&#x22;:&#x22;start_pixel&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]},{&#x22;n&#x22;:&#x22;end_pixel&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]}]" nodiscard>
    <ApiNotes>
      The conversion divides by w. If w is less than `0.0001`, `0.0001` is used in its place. The end
      points that are returned can be outside the viewport.
    </ApiNotes>
  </ApiMember>
</ApiMembers>

## ProjectionRect<ApiTag label="cdata" href="/cs2/api_reference/tutorials/ffi-crash-course#ctype-and-cdata" title="cdata<struct ProjectionRect>" />

<ApiSymbol inherits="[{&#x22;n&#x22;:&#x22;projection.Rect&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionrect-1&#x22;}]" />

A rectangle on the screen, with floating point bounds in pixels.

<ApiMembers>
  <ApiMember kind="prop" name="ProjectionRect.m_vMaxBounds" summary="The maximum x and y." ret="[[{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;}]]" />

  <ApiMember kind="prop" name="ProjectionRect.m_vMinBounds" summary="The minimum x and y." ret="[[{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;}]]" />
</ApiMembers>

## ProjectionEllipse<ApiTag label="cdata" href="/cs2/api_reference/tutorials/ffi-crash-course#ctype-and-cdata" title="cdata<struct ProjectionEllipse>" />

<ApiSymbol inherits="[{&#x22;n&#x22;:&#x22;projection.Ellipse&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionellipse-1&#x22;}]" />

The ellipse that the outline of a shape makes on the screen, in pixels. The radii are the
lengths of the half axes.

<ApiMembers>
  <ApiMember kind="prop" name="ProjectionEllipse.center" summary="The center on the screen." ret="[[{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;}]]" />

  <ApiMember kind="prop" name="ProjectionEllipse.radius_major" summary="The length of the long half axis." ret="[[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;}]]" />

  <ApiMember kind="prop" name="ProjectionEllipse.radius_minor" summary="The length of the short half axis." ret="[[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;}]]" />

  <ApiMember kind="prop" name="ProjectionEllipse.rotation" summary="The rotation of the long axis in radians, in screen coordinates." ret="[[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;}]]" />
</ApiMembers>

<Heading level={2} id="projectionrect-1">
  projection.Rect

  <ApiTag label="ctype · callable" href="/cs2/api_reference/tutorials/ffi-crash-course#ctype-and-cdata" title="ctype<struct ProjectionRect>" />
</Heading>

<ApiMembers>
  <ApiMember kind="ctor" name="projection.Rect()" summary="All bounds are zero." syntax="projection.Rect()" mm="__call" sig="[{&#x22;s&#x22;:&#x22;projection.Rect&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ProjectionRect&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionrect&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;ProjectionRect&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionrect&#x22;}]]" />

  <ApiMember kind="ctor" name="projection.Rect(min_bounds, max_bounds)" syntax="projection.Rect(min_bounds, max_bounds)" mm="__call" sig="[{&#x22;s&#x22;:&#x22;projection.Rect&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;min_bounds&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;max_bounds&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ProjectionRect&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionrect&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;ProjectionRect&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionrect&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;min_bounds&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;}]},{&#x22;n&#x22;:&#x22;max_bounds&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;}]}]" />

  <ApiMember kind="ctor" name="projection.Rect(rect)" summary="A separate copy." syntax="projection.Rect(rect)" mm="__call" sig="[{&#x22;s&#x22;:&#x22;projection.Rect&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;rect&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ProjectionRect&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionrect&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ProjectionRect&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionrect&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;ProjectionRect&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionrect&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;rect&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;ProjectionRect&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionrect&#x22;}]}]" />
</ApiMembers>

<Heading level={2} id="projectionellipse-1">
  projection.Ellipse

  <ApiTag label="ctype · callable" href="/cs2/api_reference/tutorials/ffi-crash-course#ctype-and-cdata" title="ctype<struct ProjectionEllipse>" />
</Heading>

<ApiMembers>
  <ApiMember kind="ctor" name="projection.Ellipse()" summary="All values are zero." syntax="projection.Ellipse()" mm="__call" sig="[{&#x22;s&#x22;:&#x22;projection.Ellipse&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ProjectionEllipse&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionellipse&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;ProjectionEllipse&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionellipse&#x22;}]]" />

  <ApiMember kind="ctor" name="projection.Ellipse(center, radius_major, radius_minor, rotation)" syntax="projection.Ellipse(center, radius_major, radius_minor, rotation)" mm="__call" sig="[{&#x22;s&#x22;:&#x22;projection.Ellipse&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;center&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;radius_major&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;radius_minor&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;rotation&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ProjectionEllipse&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionellipse&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;ProjectionEllipse&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionellipse&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;center&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;Vector2D&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector2#vector2d&#x22;}]},{&#x22;n&#x22;:&#x22;radius_major&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;}]},{&#x22;n&#x22;:&#x22;radius_minor&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;}]},{&#x22;n&#x22;:&#x22;rotation&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;}]}]" />

  <ApiMember kind="ctor" name="projection.Ellipse(ellipse)" summary="A separate copy." syntax="projection.Ellipse(ellipse)" mm="__call" sig="[{&#x22;s&#x22;:&#x22;projection.Ellipse&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;ellipse&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ProjectionEllipse&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionellipse&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;ProjectionEllipse&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionellipse&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;ProjectionEllipse&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionellipse&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;ellipse&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;ProjectionEllipse&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/rendering/projection#projectionellipse&#x22;}]}]" />
</ApiMembers>
