Afterbirth+ Documentation
  • README
  • beta
    • docs
      • Class "RoomConfig::Entry"
      • Class "ItemConfig::Card"
      • Class "PlayerTypes::PosVel"
      • enums
        • Enum "DoorVariant"
        • CollectibleType
        • Enum "ActionTriggers"
        • Enum "Card"
        • Enum "NpcState"
        • Enum "EffectVariant"
        • Enum "EntityGridCollisionClass"
        • Enum "EntityFlag"
        • Enum "LocustSubtypes"
        • Enum "LevelCurse"
        • Enum "GridRooms"
        • Enum "TrinketType"
        • Enum "SortingLayer"
        • Enum "ItemType"
        • Enum "GridCollisionClass"
        • Enum "ModCallbacks"
        • Enum "DoorSlot"
        • Enum "CacheFlag"
        • Enum "PillEffect"
        • Enum "EntityCollisionClass"
        • Enum "ItemPoolType"
        • Enum "PickupPrice"
        • Enum "InputHook"
        • Enum "ButtonAction"
        • Enum "PlayerSpriteLayer"
        • Enum "Keyboard"
        • Enum "GameStateFlag"
        • Enum "PillColor"
        • Enum "CoinSubType"
        • Enum "PlayerForm"
        • Enum "PickupVariant"
        • Enum "GridEntityType"
        • Enum "EntityPartition"
        • Enum "SeedEffect"
        • Enum "RoomShape"
        • Enum "Mouse"
        • Enum "TearFlags"
        • Enum "Music"
        • Enum "BabySubType"
        • Enum "BombVariant"
        • Enum "DoorState"
        • Enum "Challenge"
        • Enum "TearVariant"
        • Enum "EntityType"
        • Enum "SoundEffect"
        • Enum "FamiliarVariant"
        • Enum "PlayerType"
        • Enum "Difficulty"
        • Enum "DamageFlag"
        • Enum "Direction"
        • Enum "KeySubType"
        • Enum "LaserOffset"
        • Enum "ProjectileFlags"
        • Enum "LevelStage"
        • Enum "PlayerItemState"
        • Enum "LevelStateFlag"
        • Enum "ChestSubType"
        • Enum "ProjectileVariant"
        • Enum "WeaponType"
        • Enum "RoomType"
        • Enum "NullItemID"
        • Enum "StageType"
        • Enum "HeartSubType"
        • Enum "BombSubType"
      • Class "Isaac"
      • Class "ProjectileParams"
      • Class "Font"
      • Class "ItemPool"
      • Class "GridEntityRock"
      • tutorials
        • Class "[Tutorial]Rendertext"
        • Tutorial: Example Project
        • Class "XMLFiledocumentation"
        • Class "Writingscreenshaders"
        • Class "DebugConsole"
        • [Tutorial] Adding Costumes to items without LUA
        • Class "Usingadditional.luaFiles"
        • [Tutorial] Debugging with ZeroBrane Studio
      • Class "CppContainer::Vector::ItemConfigList"
      • Class "EntityProjectile"
      • Class "CppContainer::ArrayProxy"
      • Class "CppContainer::Vector::CardConfigList"
      • Class "PathFinder"
      • Class "ItemConfig::PillEffect"
      • Class "CppContainer::Vector::EffectList"
      • Class "RoomDescriptor"
      • Class "GridEntity"
      • Class "GridEntityPoop"
      • PLACEHOLDER
      • Class "TearParams"
      • Class "GridEntityPit"
      • Class "EntityFamiliar"
      • Class "MusicManager"
      • Class "SFXManager"
      • Lua API Documentation for The Binding of Isaac - Afterbirth+
      • Class "GridEntityTNT"
      • Class "EntityRef"
      • Class "Sprite"
      • Class "EntityBomb"
      • Class "EntityTear"
      • Class "QueueItemData"
      • Class "EntityPlayer"
      • Class "Vector"
      • Class "Entity"
      • Class "ItemConfig::Config"
      • Class "CppContainer::ArrayProxy::RoomList"
      • Class "RNG"
      • Class "EntityPtr"
      • Class "Input"
      • Class "EntityPickup"
      • Class "EntityLaser"
      • Class "GridEntityPressurePlate"
      • Class "CppContainer::Vector::VectorList"
      • Class "Room"
      • Class "CppContainer::Vector::CostumeConfigList"
      • Class "GridEntityDesc"
      • Class "Level"
      • Class "RoomConfig::Spawn"
      • Class "Color"
      • Class "KColor"
      • Class "TemporaryEffect"
      • Class "EntityKnife"
      • Class "Seeds"
      • Class "CppContainer::EntityList"
      • Class "GridEntityDoor"
      • Class "ShockwaveParams"
      • Class "ItemConfig::Costume"
      • Class "GridEntitySpikes"
      • Class "EntityEffect"
      • Class "CppContainer::Vector::PillConfigList"
      • Class "EntityNPC"
      • Class "RoomDescriptorData"
      • Class "ItemConfig::Item"
      • Class "RoomConfig::Room"
      • Class "Game"
      • Class "TemporaryEffects"
      • Class "PlayerTypes::ActiveItemDesc"
      • Class "Global Functions"
Powered by GitBook
On this page
  • Constructors
  • Vector () {: aria-label='Constructors' }
  • Functions
  • __add () {: aria-label='Functions' }
  • __div () {: aria-label='Functions' }
  • __mul () {: aria-label='Functions' }
  • __sub () {: aria-label='Functions' }
  • __unm () {: aria-label='Functions' }
  • Clamp () {: aria-label='Functions' }
  • Clamped () {: aria-label='Functions' }
  • Cross () {: aria-label='Functions' }
  • Distance () {: aria-label='Functions' }
  • DistanceSquared () {: aria-label='Functions' }
  • Dot () {: aria-label='Functions' }
  • FromAngle () {: aria-label='Functions' }
  • GetAngleDegrees () {: aria-label='Functions' }
  • Length () {: aria-label='Functions' }
  • LengthSquared () {: aria-label='Functions' }
  • Lerp () {: aria-label='Functions' }
  • Normalize () {: aria-label='Functions' }
  • Normalized () {: aria-label='Functions' }
  • Resize () {: aria-label='Functions' }
  • Resized () {: aria-label='Functions' }
  • Rotated () {: aria-label='Functions' }
  • Variables
  • X {: aria-label='Variables' }
  • Y {: aria-label='Variables' }

Was this helpful?

  1. beta
  2. docs

Class "Vector"

PreviousClass "EntityPlayer"NextClass "Entity"

Last updated 4 years ago

Was this helpful?

Constructors

() {: aria-label='Constructors' }

{: .abp .tooltip .badge }

void ( float , float ) {: .copyable aria-label='Constructors' }

Functions

__add () {: aria-label='Functions' }

{: .abp .tooltip .badge }

__add ( Right ) {: .copyable aria-label='Functions' }

Addition operators

__div () {: aria-label='Functions' }

{: .abp .tooltip .badge }

__div ( float Modifier ) {: .copyable aria-label='Functions' }

Division operators

__mul () {: aria-label='Functions' }

Multiplication operators

__sub () {: aria-label='Functions' }

Subtraction operators

__unm () {: aria-label='Functions' }

Subtraction operators

Clamp () {: aria-label='Functions' }

void Clamp ( float MinX, float MinY, float MaxX, float MaxY ) {: .copyable aria-label='Functions' }

Clamps the vector based on left, top, right, bottom boundings. Doesn't keep direction

Clamped () {: aria-label='Functions' }

Returns a clamped version of the vector.

Cross () {: aria-label='Functions' }

Cross product this is the 2x2 matrix determinant or the resulting z value for their 3D versions with z=0

Distance () {: aria-label='Functions' }

Returns distance between two vectors

???- example "Example Code"

    local sqtDist = Vector(2,0):Distance(Vector(4,0))) --sqtDist = 2

DistanceSquared () {: aria-label='Functions' }

Returns squared distance between two vectors

???- example "Example Code"

    local sqtDist = Vector(2,0):DistanceSquared(Vector(4,0))) --sqtDist = 4

Dot () {: aria-label='Functions' }

Dot product

FromAngle () {: aria-label='Functions' }

???- example "Example Code" This code returns a vector that has a 45 degree angle

    local vec = Vector.FromAngle(45)) --vec is now Vector(0.70711,0.70711)

GetAngleDegrees () {: aria-label='Functions' }

float GetAngleDegrees ( ) {: .copyable aria-label='Functions' }

Returns the angle the vector is facing. The vector (1, 0) will be at 0 degrees. The vector (0, 1) will be at 90 degrees.

???- example "Example Code" This code returns the angle between two positions.

    local v1 = Vector(1,0) -- has angle 0.0
    local v2 = Vector(0,1) -- has angle 90.0
    local v3 = v2-v1 -- subtraction of 2 points is a vector connecting the two points
    print(v3:GetAngleDegrees()) -- prints 45.0

Length () {: aria-label='Functions' }

float Length ( ) {: .copyable aria-label='Functions' }

Returns the length of the vector

LengthSquared () {: aria-label='Functions' }

float LengthSquared ( ) {: .copyable aria-label='Functions' }

Returns the length squared of the vector

Lerp () {: aria-label='Functions' }

Linear interpolation between two vectors. For t = 0 it returns the first Vector, for t = 1 it returns the second.

???- example "Alternate Function example" This function does the same as Lerp, but will not alter the input vectors.

    function Lerp(vec1, vec2, percent)
        return vec1 * (1 - percent) + vec2 * percent
    end

???- example "Example Code" This code will make v1 the vector 50% in between v1 and v2

    local v1 = Vector(0,0)
    local v2 = Vector(1,1)
    v1:Lerp(v2,0.5) -- v1 equals  Vector(0.5,0.5)  now

Normalize () {: aria-label='Functions' }

void Normalize ( ) {: .copyable aria-label='Functions' }

Normalizes this vector

Normalized () {: aria-label='Functions' }

Returns a normalized version of this vector

Resize () {: aria-label='Functions' }

void Resize ( float NewLength ) {: .copyable aria-label='Functions' }

Resizes the vector length.

Resized () {: aria-label='Functions' }

Returns a resized version of the vector.

Rotated () {: aria-label='Functions' }

Returns a rotated version of the vector by AngleDegrees

Variables

X {: aria-label='Variables' }

float X {: .copyable aria-label='Variables' }

Components of vector.

Y {: aria-label='Variables' }

float Y {: .copyable aria-label='Variables' }

{: .abp .tooltip .badge }

__mul ( float Modifier ) {: .copyable aria-label='Functions' }

{: .abp .tooltip .badge }

__sub ( Right ) {: .copyable aria-label='Functions' }

{: .abp .tooltip .badge }

__unm ( Right ) {: .copyable aria-label='Functions' }

{: .abp .tooltip .badge }

{: .abp .tooltip .badge }

Clamped ( float MinX, float MinY, float MaxX, float MaxY ) {: .copyable aria-label='Functions' }

{: .abp .tooltip .badge }

float Cross ( second ) {: .copyable aria-label='Functions' }

{: .abp .tooltip .badge }

float Distance ( first, second ) {: .copyable aria-label='Functions' }

{: .abp .tooltip .badge }

float DistanceSquared ( first, second ) {: .copyable aria-label='Functions' }

{: .abp .tooltip .badge }

float Dot ( second ) {: .copyable aria-label='Functions' }

{: .static .tooltip .badge } {: .abp .tooltip .badge }

static FromAngle ( float AngleDegrees ) {: .copyable aria-label='Functions' }

Build a from an angle, returns a normalized vector. Angle 0 will result in (1, 0). Angle 90 will result in (0, 1).

{: .abp .tooltip .badge }

{: .abp .tooltip .badge }

{: .abp .tooltip .badge }

{: .abp .tooltip .badge }

Lerp ( first, second, float t ) {: .copyable aria-label='Functions' }

{: .abp .tooltip .badge }

{: .abp .tooltip .badge }

Normalized ( ) {: .copyable aria-label='Functions' }

{: .abp .tooltip .badge }

{: .abp .tooltip .badge }

Resized ( float NewLength ) {: .copyable aria-label='Functions' }

{: .abp .tooltip .badge }

Rotated ( float AngleDegrees ) {: .copyable aria-label='Functions' }

{: .abp .tooltip .badge }

{: .abp .tooltip .badge }

Vector
Vector
Vector
Vector
Vector
Vector
Vector
Vector
Vector
Vector
Vector
Vector
Vector
Vector
Vector
Vector
Vector
Vector
Vector
Vector
Vector
Vector
Vector
Vector
Vector