pygame / doc / src / mathbase.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE module SYSTEM "api.dtd">

<module name="pygame2.math.base">
  <show>0</show>
  <alias>pygame2.math</alias>
  <short>Vector math module for Pygame2</short>
  <desc>
    Vector math module for Pygame2
  </desc>
  <func name="vector_from_polar">
    <call>vector_from_polar (p1, p2) -> Vector2</call>
    <desc>
      Creates a 2D vector from the passed polar coordinates.
    </desc>
  </func>
  <func name="vector_from_spherical">
    <call>vector_from_spherical (p1, p2, p3) -> Vector2</call>
    <desc>
      Creates a 3D vector from the passed spherical coordinates.
    </desc>
  </func>

  <class name="Vector">
    <constructor>Vector (elements) -> Vector</constructor>
    <desc>Creates a new Vector with the specified elements or dimension.
    
      Creates a new n-dimensional Vector. *elements* can be either a sequence of
      numbers representing the values for each dimension or a positive integer
      to create an empty vector with *elements* dimensions.
    </desc>
    <example>
      from pygame2.math import Vector
      
      # Create a 3D vector with x=1, y=2 and z=3
      v1 = Vector ([1, 2, 3])
      
      # Create a vector with 15 dimensions, where each component is set to 0.
      v2 = Vector (15)
    </example>
    <attr name="dimension">
      <desc>Gets the dimensions of the :class:`Vector`.</desc>
    </attr>
    <attr name="length">
      <desc>Gets the length of the :class:`Vector`.</desc>
    </attr>
    <attr name="length_squared">
      <desc>Gets the length of the :class:`Vector`.</desc>
    </attr>
    <attr name="epsilon">
      <desc>Gets or sets the exactness delta of the :class:`Vector`.
      
      epsilon represents a small fractional value to come around
      rounding issues on floating point calculations. It is usually used
      to soothe rounding differences and thus to allow the system to
      return an appropriate state, with a small tradeoff for the
      exactness.

      **Example:** ::

        (0.0000000000001 - 0.0000000000009) == 0.0

      Given that epsilon is large enough, the above calculation will be
      true. To get over rounding issues on vector operations with small
      fractional parts or to make them more exact, the concrete epsilon
      value can be freely adjusted.
      </desc>
    </attr>
    <attr name="elements">
      <desc>Gets or sets the elements of the :class:`Vector`.
    
      This will only set a maximum of :attr:`dimension` values.
      </desc>
    </attr>
    <attr name="normalized">
      <desc>Gets whether the :class:`Vector` is normalized.</desc>
    </attr>
    <method name="normalize">
      <call>normalize () -> Vector</call>
      <desc>Creates a normalized representation of this Vector.</desc>
    </method>
    <method name="normalize_ip">
      <call>normalize_ip () -> None</call>
      <desc>Normalizes the Vector in place.</desc>
    </method>
    <method name="slerp">
      <call>slerp () -> Vector</call>
      <desc></desc>
    </method>
    <method name="lerp">
      <call>lerp () -> Vector</call>
      <desc></desc>
    </method>
    <method name="dot">
      <call>dot (v) -> float</call>
      <desc>Calculates the dot product of the Vector and the passed argument.
      </desc>
    </method>
    <method name="scale_to">
      <call>scale_to (length) -> Vector</call>
      <desc>Scales the Vector to match the passed length.</desc>
    </method>
    <method name="reflect">
      <call>reflect () -> Vector</call>
      <desc>Creates a reflected representation of the Vector.</desc>
    </method>
    <method name="reflect_ip">
      <call>reflect_ip () -> None</call>
      <desc>Reflects the Vector in place.</desc>
    </method>
    <method name="distance">
      <call>distance (v) -> float</call>
      <desc>Calculates the distance between two vectors.</desc>
    </method>
    <method name="distance_squared">
      <call>distance_squared () -> None</call>
      <desc>Calculates the squared distance between two vectors.</desc>
    </method>
  </class>
  
  <class name="Vector2">
    <constructor>Vector2 () -> Vector2</constructor>
    <desc>Creates a new Vector2.
    
      A simple 2D vector containing only two elements.
    </desc>
    <attr name="dimension">
      <desc>Gets the dimensions of the :class:`Vector2`.</desc>
    </attr>
    <attr name="elements">
      <desc>Gets or sets the elements of the :class:`Vector2`.
    
        This will only set a maximum of two values.
      </desc>
    </attr>
    <attr name="x">
      <desc>Gets or sets first element of the :class:`Vector2`.</desc>
    </attr>
    <attr name="y">
      <desc>Gets or sets second element of the :class:`Vector2`.</desc>
    </attr>
    <method name="rotate">
      <call>rotate (angle) -> Vector2</call>
      <desc>Rotates the Vector2 by the passed degrees.</desc>
    </method>
    <method name="rotate_ip">
      <call>rotate_ip (angle) -> Vector2</call>
      <desc>Rotates the Vector2 by the passed degrees in place.</desc>
    </method>
    <method name="as_polar">
      <call>as_polar () -> float, float</call>
      <desc>Gets the polar coordinate representation of the Vector2.</desc>
    </method>
    <method name="angle_to">
      <call>angle_to (v) -> float</call>
      <desc>Calculates the angle (in degrees) between two Vector2 objects.</desc>
    </method>
    <method name="cross">
      <call>cross (v) -> Vector2</call>
      <desc>Creates the cross product of the two Vector2 objects.</desc>
    </method>
  </class>

  <class name="Vector3">
    <constructor>Vector3 () -> Vector3</constructor>
    <desc>Creates a new Vector3.
    
      A simple 3D vector containing only three elements.
    </desc>
    <attr name="dimension">
      <desc>Gets the dimensions of the :class:`Vector3`.</desc>
    </attr>
    <attr name="elements">
      <desc>Gets or sets the elements of the :class:`Vector3`.
    
        This will only set a maximum of three values.
      </desc>
    </attr>
    <attr name="x">
      <desc>Gets or sets first element of the :class:`Vector3`.</desc>
    </attr>
    <attr name="y">
      <desc>Gets or sets second element of the :class:`Vector3`.</desc>
    </attr>
    <attr name="z">
      <desc>Gets or sets third element of the :class:`Vector3`.</desc>
    </attr>
    <method name="rotate_x">
      <call>rotate_x (angle) -> Vector3</call>
      <desc>Rotates the Vector3 by the passed degrees around the x-axis.</desc>
    </method>
    <method name="rotate_x_ip">
      <call>rotate_x_ip (angle) -> None</call>
      <desc>Rotates the Vector3 by the passed degrees in place around the x-axis.
      </desc>
    </method>
    <method name="rotate_y">
      <call>rotate_y (angle) -> Vector3</call>
      <desc>Rotates the Vector3 by the passed degrees around the y-axis.</desc>
    </method>
    <method name="rotate_y_ip">
      <call>rotate_y_ip (angle) -> None</call>
      <desc>Rotates the Vector3 by the passed degrees in place around the y-axis.</desc>
    </method>
    <method name="rotate_z">
      <call>rotate_z (angle) -> Vector3</call>
      <desc>Rotates the Vector3 by the passed degrees around the z-axis.</desc>
    </method>
    <method name="rotate_z_ip">
      <call>rotate_z_ip (angle) -> None</call>
      <desc>Rotates the Vector3 by the passed degrees in place around the z-axis.</desc>
    </method>
    <method name="rotate">
      <call>rotate (angle, axis) -> Vector3</call>
      <desc>Rotates the Vector3 by the passed degrees around the passed axis vector.
      </desc>
    </method>
    <method name="rotate_ip">
      <call>rotate_ip (angle, axis) -> Vector3</call>
      <desc>Rotates the Vector3 by the passed degrees in place around the passed axis vector.
      </desc>
    </method>
    <method name="angle_to">
      <call>angle_to (v) -> float</call>
      <desc>Calculates the angle between two vectors in degrees</desc>
    </method>
    <method name="cross">
      <call>cross (v) -> Vector3</call>
      <desc>Calculates the cross product between the two Vector3 instances.</desc>
    </method>
    <method name="as_spherical">
      <call>as_spherical () -> float, float, float</call>
      <desc>Gets the sperhical coordinate representation of the Vector3.</desc>
    </method>
  </class>

</module>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.