Basic FunctionalityData StructureVec2On this pageVec2 Description: A record representing a 2D vector with an x and y component. Class Object: Vec2 Class. Inherits from: ContainerItem. x Type: Readonly Field. Description: The x-component of the vector. Signature: const x: number y Type: Readonly Field. Description: The y-component of the vector. Signature: const y: number length Type: Readonly Field. Description: The length of the vector. Signature: const length: number lengthSquared Type: Readonly Field. Description: The squared length of the vector. Signature: const lengthSquared: number angle Type: Readonly Field. Description: The angle between the vector and the x-axis. Signature: const angle: number distance Type: Function. Description: Calculates the distance between two vectors. Signature: distance: function(self: Vec2, vec: Vec2): number Parameters: ParameterTypeDescriptionvecVec2The other vector to calculate the distance to. Returns: Return TypeDescriptionnumberThe distance between the two vectors. distanceSquared Type: Function. Description: Calculates the squared distance between two vectors. Signature: distanceSquared: function(self: Vec2, vec: Vec2): number Parameters: ParameterTypeDescriptionvecVec2The other vector to calculate the squared distance to. Returns: Return TypeDescriptionnumberThe squared distance between the two vectors. normalize Type: Function. Description: Normalizes the vector to have a length of 1. Signature: normalize: function(self: Vec2): Vec2 Returns: Return TypeDescriptionVec2The normalized vector. perp Type: Function. Description: Gets the perpendicular vector of this vector. Signature: perp: function(self: Vec2): Vec2 Returns: Return TypeDescriptionVec2The perpendicular vector. clamp Type: Function. Description: Clamps the vector to a range between two other vectors. Signature: clamp: function(self: Vec2, from: Vec2, to: Vec2): Vec2 Parameters: ParameterTypeDescriptionfromVec2The lower bound of the range.toVec2The upper bound of the range. Returns: Return TypeDescriptionVec2The clamped vector. dot Type: Function. Description: Gets the dot product of two vectors. Signature: dot: function(self: Vec2, other: Vec2): number Parameters: ParameterTypeDescriptionotherVec2The other vector to calculate the dot product with. Returns: Return TypeDescriptionnumberThe dot product of the two vectors. add Type: Function. Description: Adds two vectors together. Signature: add: function(self: Vec2, other: Vec2): Vec2 Parameters: ParameterTypeDescriptionotherVec2The other vector to add. Returns: Return TypeDescriptionVec2The sum of the two vectors. sub Type: Function. Description: Subtracts one vector from another. Signature: sub: function(self: Vec2, other: Vec2): Vec2 Parameters: ParameterTypeDescriptionotherVec2The vector to subtract. Returns: Return TypeDescriptionVec2The difference between the two vectors. mul Type: Function. Description: Multiplies two vectors component-wise. Signature: mul: function(self: Vec2, other: Vec2): Vec2 Parameters: ParameterTypeDescriptionotherVec2The other vector to multiply by. Returns: Return TypeDescriptionVec2The result of multiplying the two vectors component-wise. mul Type: Function. Description: Multiplies a vector by a scalar. Signature: mul: function(self: Vec2, other: number): Vec2 Parameters: ParameterTypeDescriptionotherVec2The scalar to multiply by, represented by a number. Returns: Return TypeDescriptionVec2The result of multiplying the vector by the scalar. mul Type: Function. Description: Multiplies a vector by a Size object. Signature: mul: function(self: Vec2, other: Dora.Size.Type): Vec2 Usage: local halfVec = vec * Size(0.5, 0.5) Parameters: ParameterTypeDescriptionotherSizeThe Size object to multiply by. Returns: Return TypeDescriptionVec2The result of multiplying the vector by the Size object. div Type: Function. Description: Divide a vector by a scalar. Signature: div: function(self: Vec2, other: number): Vec2 Parameters: ParameterTypeDescriptionothernumberThe scalar to divide by, represented by a number. Returns: Return TypeDescriptionVec2The result of dividing the vector by the scalar. equals Type: Function. Description: Compare two vectors for equality. Signature: equals: function(self: Vec2, other: Vec2): boolean Parameters: ParameterTypeDescriptionotherVec2The other vector to compare to. Returns: Return TypeDescriptionbooleanWhether or not the two vectors are equal. __add Type: Metamethod. Description: Adds two vectors together. Signature: metamethod __add: function(self: Vec2, other: Vec2): Vec2 Parameters: ParameterTypeDescriptionotherVec2The other vector to add. Returns: Return TypeDescriptionVec2The sum of the two vectors. __sub Type: Metamethod. Description: Subtracts one vector from another. Signature: metamethod __sub: function(self: Vec2, other: Vec2): Vec2 Parameters: ParameterTypeDescriptionotherVec2The vector to subtract. Returns: Return TypeDescriptionVec2The difference between the two vectors. __mul Type: Metamethod. Description: Multiplies two vectors component-wise. Signature: metamethod __mul: function(self: Vec2, other: Vec2): Vec2 Parameters: ParameterTypeDescriptionotherVec2The other vector to multiply by. Returns: Return TypeDescriptionVec2The result of multiplying the two vectors component-wise. __mul Type: Metamethod. Description: Multiplies a vector by a scalar. Signature: metamethod __mul: function(self: Vec2, other: number): Vec2 Parameters: ParameterTypeDescriptionotherVec2The scalar to multiply by, represented by a number. Returns: Return TypeDescriptionVec2The result of multiplying the vector by the scalar. __mul Type: Metamethod. Description: Multiplies a vector by a Size object. Signature: metamethod __mul: function(self: Vec2, other: Dora.Size.Type): Vec2 Usage: local halfVec = vec * Size(0.5, 0.5) Parameters: ParameterTypeDescriptionotherSizeThe Size object to multiply by. Returns: Return TypeDescriptionVec2The result of multiplying the vector by the Size object. __div Type: Metamethod. Description: Divide a vector by a scalar. Signature: metamethod __div: function(self: Vec2, other: number): Vec2 Parameters: ParameterTypeDescriptionothernumberThe scalar to divide by, represented by a number. Returns: Return TypeDescriptionVec2The result of dividing the vector by the scalar. __eq Type: Metamethod. Description: Compare two vectors for equality. Signature: metamethod __eq: function(self: Vec2, other: Vec2): boolean Parameters: ParameterTypeDescriptionotherVec2The other vector to compare to. Returns: Return TypeDescriptionbooleanWhether or not the two vectors are equal.