Libraries.Game.Physics.Mass2D Documentation

Mass2D is a class representing a mass in 2D space.

Example Code

use Libraries.Game.Physics.Mass2D
use Libraries.Compute.Vector2

Vector2 vectorSetting
vectorSetting:Set(8.0, 9.0)
Mass2D mass
mass:SetMass(5.0)
mass:SetInertia(2.0)
mass:SetCenter(vectorSetting)

number newMass = mass:GetMass()
number newInertia = mass:GetInertia()
number newX = mass:GetCenter():GetX()
number newY = mass:GetCenter():GetY()
output "The new mass has a mass of " + newMass + ", inertia of: " + newInertia + ", x center at: " + newX + ", and y center at: " + newY

Inherits from: Libraries.Language.Object

Summary

Actions Summary Table

ActionsDescription
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns an integer.
Copy()This action returns a copy of the current mass.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
GetCenter()This action gets the vector that points to the center of the mass in 2D.
GetHashCode()This action gets the hash code for an object.
GetInertia()This action sets the inertia of a mass in 2D space.
GetMass()This action returns the mass of a mass in 2D space.
Set(Libraries.Game.Physics.Mass2D mass)This action sets the properties of a 2D mass using another 2D mass.
SetCenter(Libraries.Compute.Vector2 center)This action sets the vector that points to the center of a mass in 2D space.
SetInertia(number inertia)This action sets the inertia of a mass in 2D space.
SetMass(number mass)This action sets the value of mass of a mass in 2D space.

Actions Documentation

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Example Code

Object o
        Object t
        integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Copy()

This action returns a copy of the current mass. The copied mass will have the same mass, center, and inertia as the current mass.

Example Code

use Libraries.Game.Physics.Mass2D
    use Libraries.Compute.Vector2

    Vector2 vectorSetting
    vectorSetting:Set(8.0, 9.0)
    Mass2D massBeingCopied

    //setting the mass that we will copy
    massBeingCopied:SetMass(5.0)
    massBeingCopied:SetInertia(2.0)
    massBeingCopied:SetCenter(vectorSetting)


    //copy the mass
    Mass2D copyMass
    copyMass = massBeingCopied:Copy()
    number copiedMass = copyMass:GetMass()
    number copiedInertia = copyMass:GetInertia()
    number copiedX = copyMass:GetCenter():GetX()
    number copiedY = copyMass:GetCenter():GetY()
    output "The copy of the mass has a mass of " + copiedMass + ", inertia of: " + copiedInertia + ", x center at: " + copiedX + ", and y center at: " + copiedY

Return

Libraries.Game.Physics.Mass2D: a mass in 2D space.

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Example Code

use Libraries.Language.Object
        use Libraries.Language.Types.Text
        Object o
        Text t
        boolean result = o:Equals(t)

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

GetCenter()

This action gets the vector that points to the center of the mass in 2D.

Example Code

use Libraries.Game.Physics.Mass2D
    use Libraries.Compute.Vector2

    Vector2 centerOfMassSetting
    centerOfMassSetting:Set(1.0, 3.0)

    Mass2D mass
    mass:SetCenter(centerOfMassSetting)

    Vector2 centerOfMass
    centerOfMass = mass:GetCenter()

    number xComponent = centerOfMass:GetX()
    number yComponent = centerOfMass:GetY()
    output "The center of mass vector is: <" + xComponent + ", " + yComponent + ">"

Return

Libraries.Compute.Vector2: a 2D vector that points to the center of the mass in 2D.

GetHashCode()

This action gets the hash code for an object.

Example Code

Object o
        integer hash = o:GetHashCode()

Return

integer: The integer hash code of the object.

GetInertia()

This action sets the inertia of a mass in 2D space.

Example Code

use Libraries.Game.Physics.Mass2D

    number inertiaSetting = 5.0
    Mass2D mass
    mass:SetInertia(inertiaSetting)

    number inertiaValue = mass:GetInertia()
    output "The inertia of mass in 2D is: " + inertiaValue

Return

number: the value of inertia of the current 2D mass.

GetMass()

This action returns the mass of a mass in 2D space.

Example Code

use Libraries.Game.Physics.Mass2D

    Mass2D mass
    mass:SetMass(0.5)

    number massValue = mass:GetMass()
    output "The mass that you have set is: " + massValue

Return

number: the value of mass.

Set(Libraries.Game.Physics.Mass2D mass)

This action sets the properties of a 2D mass using another 2D mass.

Example Code

use Libraries.Game.Physics.Mass2D
    use Libraries.Compute.Vector2

    Vector2 vectorSetting
    vectorSetting:Set(8.0, 9.0)
    Mass2D mass1
    Mass2D mass2
    mass1:SetMass(5.0)
    mass1:SetInertia(2.0)
    mass1:SetCenter(vectorSetting)

    mass2:Set(mass1)
    number newMass = mass2:GetMass()
    number newInertia = mass2:GetInertia()
    number newX = mass2:GetCenter():GetX()
    number newY = mass2:GetCenter():GetY()
    output "The new mass has a mass of " + newMass + ", inertia of: " + newInertia + ", x center at: " + newX + ", and y center at: " + newY

Parameters

SetCenter(Libraries.Compute.Vector2 center)

This action sets the vector that points to the center of a mass in 2D space.

Example Code

use Libraries.Game.Physics.Mass2D
    use Libraries.Compute.Vector2

    Vector2 centerOfMassSetting
    centerOfMassSetting:Set(1.0, 3.0)

    Mass2D mass
    mass:SetCenter(centerOfMassSetting)

    Vector2 centerOfMass
    centerOfMass = mass:GetCenter()

    number xComponent = centerOfMass:GetX()
    number yComponent = centerOfMass:GetY()
    output "The center of mass vector is: <" + xComponent + ", " + yComponent + ">"

Parameters

SetInertia(number inertia)

This action sets the inertia of a mass in 2D space.

Example Code

use Libraries.Game.Physics.Mass2D

    number inertiaSetting = 5.0
    Mass2D mass
    mass:SetInertia(inertiaSetting)

    number inertiaValue = mass:GetInertia()
    output "The inertia of mass in 2D is: " + inertiaValue

Parameters

SetMass(number mass)

This action sets the value of mass of a mass in 2D space.

Example Code

use Libraries.Game.Physics.Mass2D

    Mass2D mass
    mass:SetMass(5.5)

    number massValue = mass:GetMass()
    output "The mass of this mass in 2D is: " + massValue

Parameters