Kraken Logo

Kraken Engine

DocumentationGuidesShowcaseCommunity
Ctrl
K
Navigating the Docs
Building Docs
Overview
Camera
Color
Draw
Ease
Event
Fx
Gamepad
Input
Log
Math
Mixer
Mouse
Physics
Pixel Array
Renderer
Shaders
Time
Transform
Ui
Viewport
Window

Built bydurkisneer1.Kraken Engine is open source and available onGitHub.

  1. Docs
  2. Functions
  3. Math

Math

Math related functions


From Polar

from_polar(angle: float, radius: float) → Vec2from_polar(angle: float, radius: float) → Vec2

Convert polar coordinates to a Cartesian vector.

Args

  • angle : The angle in radians.
  • radius : The radius/distance from origin.

Returns

Vec2 : The equivalent Cartesian vector.

Remap

remap(in_min: float, in_max: float, out_min: float, out_max: float, value: float) → floatremap(in_min: float, in_max: float, out_min: float, out_max: float, value: float) → float

Remap a value from one range to another.

Args

  • in_min : Input range minimum.
  • in_max : Input range maximum.
  • out_min : Output range minimum.
  • out_max : Output range maximum.
  • value : The value to remap.

Returns

float : The remapped value in the output range.

Raises

  • ValueError : If in_min equals in_max.

Dot

dot(a: Vec2, b: Vec2) → floatdot(a: Vec2, b: Vec2) → float

Calculate the dot product of two vectors.

Args

  • a : The first vector.
  • b : The second vector.

Returns

float : The dot product (a.x * b.x + a.y * b.y).

Cross

cross(a: Vec2, b: Vec2) → floatcross(a: Vec2, b: Vec2) → float

Calculate the 2D cross product of two vectors. (a.x * b.y - a.y * b.x)

Args

  • a : The first vector.
  • b : The second vector.

Returns

float : The 2D cross product.

Angle Between

angle_between(a: Vec2, b: Vec2) → floatangle_between(a: Vec2, b: Vec2) → float

Calculate the angle between two vectors.

Args

  • a : The first vector.
  • b : The second vector.

Returns

float : The angle between the vectors in radians [0, π].

Move Toward

move_toward(current: float, target: float, delta: float) → floatmove_toward(current: float, target: float, delta: float) → float

Move a value toward a target by a maximum delta.

Args

  • current : The current value.
  • target : The target value.
  • delta : The maximum amount to move toward the target.

Returns

float : The new value after moving toward the target.

PreviousLog
NextMixer

On this page

From PolarRemapDotCrossAngle BetweenMove Toward