<no title> — MCPQ 1.0.0 documentation

MCPQ 1.0.0 documentation

class Vec3(x: float = 0, y: float = 0, z: float = 0)

  `Vec3` is a 3-dimensional vector for representing `x`, `y` and `z` coordinates. Each instance of this class is frozen, so calculations on it yield new instances of `Vec3` instead of changing the x, y and z values directly.

  x: float
  y: float
  z: float
  classmethod from_yaw_pitch(yaw: int | float = 0, pitch: int | float = 0) → Vec3

    Build direction unit-vector from yaw and pitch values. This translate the in-Minecraft yaw and pitch values of entities or players (in which direction they are looking) into directional unit-vectors.

    - yaw: -180..179.99 (-180/180 north, -90 east, 0 south, 90 west)

    - pitch: -90..90 (-90 up, 0 straight, 90 down)

  yaw_pitch() → tuple[float, float]

    The yaw and pitch values from self as directional vector. This translates directional unit-vectors into in-Minecraft yaw and pitch values used by entities or players (in which direction they are looking).

    - yaw: -180..179.99 (-180 north, -90 east, 0 south, 90 west)

    - pitch: -90..90 (-90 up, 0 straight, 90 down)

  length() → float

    The (absolute) length of vector self, equivalent to `abs(self)`

  distance(v: Vec3) → float

    The distance between self and another point-vector v

  angle(v: Vec3) → float

    Get the angle between self and v in degrees (0 <= theta <= 180)

  angle_rad(v: Vec3) → float

    Get the angle between self and v in radians (0 <= theta <= pi)

  dot(v: Vec3) → float

    The dot product between self and v, equivalent to `self ^ v`

  cross(v: Vec3) → Vec3

    The cross product between self and v, equivalent to `self @ v`

  multiply_elementwise(v: Vec3) → Vec3

    The element-wise multiplicated vector of self and v, equivalent to `self * v`

  norm() → Vec3

    self as a normalized unit-vector with length 1

  map(func: Callable[[int | float], int | float]) → Vec3

    A vector with func applied to x, y and z of self as arguments

  map_pairwise(func: Callable[[int | float, int | float], int | float], v: Vec3) → Vec3

    A vector with func applied to each x, y and z of both self and v as arguments

  rotate(v: Vec3, degree: float) → Vec3

    Rotate self around vector v by degree degrees

  rotate_rad(v: Vec3, phi: float) → Vec3

    Rotate self around vector v by phi degree radians - Rodrigues rotation

  round(ndigits: int = 0) → Vec3

    Round x, y and z to the ndigits comma digit

  floor() → Vec3

    Round x, y and z down to the nearest integer

  ceil() → Vec3

    Round x, y and z up to the nearest integer

  trunc() → Vec3

    Leave only the integer part of x, y and z

  asdict() → dict[str, int | float]

    x, y and z in a dictionary

  closest_axis() → Vec3

    A vector with only the longest (most significant) axis remaining

  direction_label() → Literal['east', 'south', 'west', 'north', 'up', 'down']

    The direction of the longest (most significant) axis

  cardinal_label() → Literal['east', 'south', 'west', 'north']

    The direction of the longest (most significant) cardinal axis

  east(n: int | float = 1) → Vec3

    Equivalent to `self.addX(n)`

  west(n: int | float = 1) → Vec3

    Equivalent to `self.addX(-n)`

  up(n: int | float = 1) → Vec3

    Equivalent to `self.addY(n)`

  down(n: int | float = 1) → Vec3

    Equivalent to `self.addY(-n)`

  south(n: int | float = 1) → Vec3

    Equivalent to `self.addZ(n)`

  north(n: int | float = 1) → Vec3

    Equivalent to `self.addZ(-n)`

  addX(n: int | float = 1) → Vec3

    self with n added to x, equivalent to `self + Vec3(n, 0, 0)`

  addY(n: int | float = 1) → Vec3

    self with n added to y, equivalent to `self + Vec3(0, n, 0)`

  addZ(n: int | float = 1) → Vec3

    self with n added to z, equivalent to `self + Vec3(0, 0, n)`

  addXY(n: int | float = 1) → Vec3

    self with n added to x and y, equivalent to `self + Vec3(n, n, 0)`

  addXZ(n: int | float = 1) → Vec3

    self with n added to x and z, equivalent to `self + Vec3(n, 0, n)`

  addYZ(n: int | float = 1) → Vec3

    self with n added to y and z, equivalent to `self + Vec3(0, n, n)`

  withX(n: int | float) → Vec3

    self with x replaced with n, equivalent to `Vec3(n, self.y, self.z)`

  withY(n: int | float) → Vec3

    self with y replaced with n, equivalent to `Vec3(self.x, n, self.z)`

  withZ(n: int | float) → Vec3

    self with z replaced with n, equivalent to `Vec3(self.x, self.y, n)`

  withXY(n: int | float) → Vec3

    self with x and y replaced with n, equivalent to `Vec3(n, n, self.z)`

  withXZ(n: int | float) → Vec3

    self with x and z replaced with n, equivalent to `Vec3(n, self.y, n)`

  withYZ(n: int | float) → Vec3

    self with y and z replaced with n, equivalent to `Vec3(self.x, n, n)`