Search Results for

    Show / Hide Table of Contents

    Class Math

    Common math help functions.

    Inheritance
    object
    Math
    Syntax
    public static class Math

    Fields

    MaxValue

    Declaration
    public static readonly float MaxValue
    Field Value
    Type Description
    float

    MaxVector

    Declaration
    public static readonly Vector3 MaxVector
    Field Value
    Type Description
    UnityEngine.Vector3

    Methods

    Abs(Vector3)

    Applies absolute value of to each vector component.

    Declaration
    public static Vector3 Abs(Vector3 v)
    Parameters
    Type Name Description
    UnityEngine.Vector3 v

    The vector to apply absolute value to.

    Returns
    Type Description
    UnityEngine.Vector3

    The vector with absolute value applied.

    Align(float, Align)

    Determines the aligned position in a size.

    Declaration
    public static float Align(float size, Align align)
    Parameters
    Type Name Description
    float size

    The size to align to.

    Align align

    The alignment.

    Returns
    Type Description
    float

    The aligned position.

    Align(float, float, Align, Align)

    Aligns a child size to a parent size.

    Declaration
    public static float Align(float childSize, float parentSize, Align parentAlign, Align childAlign)
    Parameters
    Type Name Description
    float childSize

    The size of the child.

    float parentSize

    The size of the parent.

    Align parentAlign

    The alignment of the parent.

    Align childAlign

    The pivot of the child.

    Returns
    Type Description
    float

    The aligned position of the child.

    Align(float, float, Align)

    Aligns a child size to a parent size.

    Declaration
    public static float Align(float childSize, float parentSize, Align align)
    Parameters
    Type Name Description
    float childSize

    The size of the child.

    float parentSize

    The size of the parent.

    Align align

    The alignment of the parent and child.

    Returns
    Type Description
    float

    The aligned position of the child.

    Align(Vector3, Align, Align, Align)

    Determines the aligned position in a size.

    Declaration
    public static Vector3 Align(Vector3 size, Align horizontal, Align vertical, Align depth)
    Parameters
    Type Name Description
    UnityEngine.Vector3 size

    The size to align to.

    Align horizontal

    The horizontal alignment.

    Align vertical

    The vertical alignment.

    Align depth

    The depth alignment.

    Returns
    Type Description
    UnityEngine.Vector3

    The aligned position.

    Align(Vector3, int, Align)

    Determines the aligned position in a size for an axis.

    Declaration
    public static float Align(Vector3 size, int axis, Align align)
    Parameters
    Type Name Description
    UnityEngine.Vector3 size

    The size to align to.

    int axis

    The axis to align to.

    Align align

    The alignment.

    Returns
    Type Description
    float

    The aligned position.

    Align(Vector3, Vector3, Align, Align, Align, Align, Align, Align)

    Aligns a child size to a parent size on all axes.

    Declaration
    public static Vector3 Align(Vector3 childSize, Vector3 parentSize, Align parentHorizontal, Align parentVertical, Align parentDepth, Align childHorizontal, Align childVertical, Align childDepth)
    Parameters
    Type Name Description
    UnityEngine.Vector3 childSize

    The size of the child.

    UnityEngine.Vector3 parentSize

    The size of the parent.

    Align parentHorizontal

    The horizontal alignment of the parent.

    Align parentVertical

    The vertical alignment of the parent.

    Align parentDepth

    The depth alignment of the parent.

    Align childHorizontal

    The horizontal pivot of the child.

    Align childVertical

    The vertical pivot of the child.

    Align childDepth

    The depth pivot of the child.

    Returns
    Type Description
    UnityEngine.Vector3

    The aligned position of the child.

    Align(Vector3, Vector3, Align, Align, Align)

    Aligns a child size to a parent size on all axes.

    Declaration
    public static Vector3 Align(Vector3 childSize, Vector3 parentSize, Align horizontal, Align vertical, Align depth)
    Parameters
    Type Name Description
    UnityEngine.Vector3 childSize

    The size of the child.

    UnityEngine.Vector3 parentSize

    The size of the parent.

    Align horizontal

    The horizontal alignment of the parent and child.

    Align vertical

    The vertical alignment of the parent and child.

    Align depth

    The depth alignment of the parent and child.

    Returns
    Type Description
    UnityEngine.Vector3

    The aligned position of the child.

    Align(Vector3, Vector3, Axis, Align, Align)

    Aligns a child size to a parent size on an axis.

    Declaration
    public static float Align(Vector3 childSize, Vector3 parentSize, Axis axis, Align parentAlign, Align childAlign)
    Parameters
    Type Name Description
    UnityEngine.Vector3 childSize

    The size of the child.

    UnityEngine.Vector3 parentSize

    The size of the parent.

    Axis axis

    The axis to align on.

    Align parentAlign

    The alignment of the parent.

    Align childAlign

    The pivot of the child.

    Returns
    Type Description
    float

    The aligned position of the child.

    Align(Vector3, Vector3, Axis, Align)

    Aligns a child size to a parent size on an axis.

    Declaration
    public static float Align(Vector3 childSize, Vector3 parentSize, Axis axis, Align align)
    Parameters
    Type Name Description
    UnityEngine.Vector3 childSize

    The size of the child.

    UnityEngine.Vector3 parentSize

    The size of the parent.

    Axis axis

    The axis to align on.

    Align align

    The alignment of the parent and child.

    Returns
    Type Description
    float

    The aligned position of the child.

    Align(Vector3, Vector3, int, Align, Align)

    Aligns a child size to a parent size on an axis.

    Declaration
    public static float Align(Vector3 childSize, Vector3 parentSize, int axis, Align parentAlign, Align childAlign)
    Parameters
    Type Name Description
    UnityEngine.Vector3 childSize

    The size of the child.

    UnityEngine.Vector3 parentSize

    The size of the parent.

    int axis

    The axis to align on.

    Align parentAlign

    The alignment of the parent.

    Align childAlign

    The pivot of the child.

    Returns
    Type Description
    float

    The aligned position of the child.

    Align(Vector3, Vector3, int, Align)

    Aligns a child size to a parent size on an axis.

    Declaration
    public static float Align(Vector3 childSize, Vector3 parentSize, int axis, Align align)
    Parameters
    Type Name Description
    UnityEngine.Vector3 childSize

    The size of the child.

    UnityEngine.Vector3 parentSize

    The size of the parent.

    int axis

    The axis to align on.

    Align align

    The alignment of the parent and child.

    Returns
    Type Description
    float

    The aligned position of the child.

    Clamp(Vector3, Vector3, Vector3)

    Clamps value of to each vector component between min and max.

    Declaration
    public static Vector3 Clamp(Vector3 v, Vector3 min, Vector3 max)
    Parameters
    Type Name Description
    UnityEngine.Vector3 v

    The vector to clamp.

    UnityEngine.Vector3 min

    The minimum value.

    UnityEngine.Vector3 max

    The maximum value.

    Returns
    Type Description
    UnityEngine.Vector3

    The clamped vector.

    CreateRotatedBounds(Vector3, Vector3, Quaternion)

    Creates rotated and scaled bounds at center.

    Declaration
    public static Bounds CreateRotatedBounds(Vector3 center, Vector3 size, Quaternion rotation)
    Parameters
    Type Name Description
    UnityEngine.Vector3 center

    The center of the bounds.

    UnityEngine.Vector3 size

    The size of the bound before rotation.

    UnityEngine.Quaternion rotation

    The rotation to apply to the size.

    Returns
    Type Description
    UnityEngine.Bounds

    Div(Vector3, Vector3)

    Divides each component of two vectors.

    Declaration
    public static Vector3 Div(Vector3 a, Vector3 b)
    Parameters
    Type Name Description
    UnityEngine.Vector3 a

    The divided vector.

    UnityEngine.Vector3 b

    The divisor vector.

    Returns
    Type Description
    UnityEngine.Vector3

    The divided vector.

    GetAxisFromDirection(Direction)

    Returns the axis of a direction.

    Declaration
    public static Axis GetAxisFromDirection(Direction direction)
    Parameters
    Type Name Description
    Direction direction

    The direction to get the axis of.

    Returns
    Type Description
    Axis

    The axis of the direction.

    GetAxisFromDirection(int)

    Returns the axis of a direction.

    Declaration
    public static Axis GetAxisFromDirection(int direction)
    Parameters
    Type Name Description
    int direction

    The direction to get the axis of.

    Returns
    Type Description
    Axis

    The axis of the direction.

    GetDirectionsFromAxis(Axis)

    Returns the positive and negative directions of an axis.

    Declaration
    public static (Direction, Direction) GetDirectionsFromAxis(Axis axis)
    Parameters
    Type Name Description
    Axis axis

    The axis to get the directions of.

    Returns
    Type Description
    (Direction, Direction)

    The positive and negative directions of the axis.

    GetDirectionsFromAxis(int)

    Returns the positive and negative directions of an axis.

    Declaration
    public static (Direction, Direction) GetDirectionsFromAxis(int axis)
    Parameters
    Type Name Description
    int axis

    The axis to get the directions of.

    Returns
    Type Description
    (Direction, Direction)

    The positive and negative directions of the axis.

    GetOppositeDirection(Direction)

    Returns the opposite direction.

    Declaration
    public static Direction GetOppositeDirection(Direction direction)
    Parameters
    Type Name Description
    Direction direction

    The direction to get the opposite of.

    Returns
    Type Description
    Direction

    The opposite direction.

    GetOppositeDirection(int)

    Returns the opposite direction.

    Declaration
    public static Direction GetOppositeDirection(int direction)
    Parameters
    Type Name Description
    int direction

    The direction to get the opposite of.

    Returns
    Type Description
    Direction

    The opposite direction.

    GetOtherAxes(Axis)

    Returns the other two axes.

    Declaration
    public static (Axis, Axis) GetOtherAxes(Axis axis)
    Parameters
    Type Name Description
    Axis axis

    The axis to get the other two axes of.

    Returns
    Type Description
    (Axis, Axis)

    The other two axes.

    GetOtherAxes(int)

    Returns the other two axes.

    Declaration
    public static (int, int) GetOtherAxes(int axis)
    Parameters
    Type Name Description
    int axis

    The axis to get the other two axes of.

    Returns
    Type Description
    (int, int)

    The other two axes.

    GetPlaneAxes(Plane)

    Returns the axes of a plane.

    Declaration
    public static (Axis, Axis) GetPlaneAxes(Plane plane)
    Parameters
    Type Name Description
    Plane plane

    The plane to get the axes of.

    Returns
    Type Description
    (Axis, Axis)

    The axes of the plane.

    GetPlaneAxesInt(Plane)

    Returns the axes of a plane.

    Declaration
    public static (int, int) GetPlaneAxesInt(Plane plane)
    Parameters
    Type Name Description
    Plane plane

    The plane to get the axes of.

    Returns
    Type Description
    (int, int)

    The axes of the plane.

    GetPositiveFromDirection(Direction)

    Returns the positive direction of an axis.

    Declaration
    public static float GetPositiveFromDirection(Direction direction)
    Parameters
    Type Name Description
    Direction direction
    Returns
    Type Description
    float

    The positive direction of the axis.

    GetPositiveFromDirection(int)

    Returns the positive direction of an axis.

    Declaration
    public static float GetPositiveFromDirection(int direction)
    Parameters
    Type Name Description
    int direction
    Returns
    Type Description
    float

    The positive direction of the axis.

    GetThirdAxis(Axis, Axis)

    Given two axes, returns the third axis.

    Declaration
    public static Axis GetThirdAxis(Axis axis1, Axis axis2)
    Parameters
    Type Name Description
    Axis axis1

    The first axis.

    Axis axis2

    The second axis.

    Returns
    Type Description
    Axis

    The third axis.

    GetThirdAxis(int, int)

    Given two axes, returns the third axis.

    Declaration
    public static int GetThirdAxis(int axis1, int axis2)
    Parameters
    Type Name Description
    int axis1

    The first axis.

    int axis2

    The second axis.

    Returns
    Type Description
    int

    The third axis.

    GetVectorFromAxis(Axis)

    Returns a unit vector in the positive direction of axis.

    Declaration
    public static Vector3 GetVectorFromAxis(Axis axis)
    Parameters
    Type Name Description
    Axis axis

    The axis to get the vector of.

    Returns
    Type Description
    UnityEngine.Vector3

    A unit vector in the axis.

    GetVectorFromAxis(int)

    Returns a unit vector in the positive direction of axis.

    Declaration
    public static Vector3 GetVectorFromAxis(int axis)
    Parameters
    Type Name Description
    int axis

    The axis to get the vector of.

    Returns
    Type Description
    UnityEngine.Vector3

    A unit vector in the axis.

    GetVectorFromDirection(Direction)

    Returns a unit vector in the direction.

    Declaration
    public static Vector3 GetVectorFromDirection(Direction direction)
    Parameters
    Type Name Description
    Direction direction

    The direction to get the vector of.

    Returns
    Type Description
    UnityEngine.Vector3

    A unit vector in the direction.

    GetVectorFromDirection(int)

    Returns a unit vector in the direction.

    Declaration
    public static Vector3 GetVectorFromDirection(int direction)
    Parameters
    Type Name Description
    int direction

    The direction to get the vector of.

    Returns
    Type Description
    UnityEngine.Vector3

    A unit vector in the direction.

    MeasureComponentBounds(Bounds, FlexalonNode, Vector3, Vector3, Vector3)

    Given the bounds of a component, creates a bounds for the node respecting the size types. Aspect ratio is preserved when possible.

    Declaration
    public static Bounds MeasureComponentBounds(Bounds componentBounds, FlexalonNode node, Vector3 size, Vector3 min, Vector3 max)
    Parameters
    Type Name Description
    UnityEngine.Bounds componentBounds

    The bounds of the component.

    FlexalonNode node

    The node to measure the bounds for.

    UnityEngine.Vector3 size

    The size of the node.

    UnityEngine.Vector3 min

    The minimum size of the node.

    UnityEngine.Vector3 max

    The maximum size of the node.

    Returns
    Type Description
    UnityEngine.Bounds

    The bounds of the node.

    MeasureComponentBounds2D(Bounds, FlexalonNode, Vector3, Vector3, Vector3)

    Given the bounds of a component, creates a bounds for the node respecting the size types. Aspect ratio is preserved for X and Y when possible.

    Declaration
    public static Bounds MeasureComponentBounds2D(Bounds componentBounds, FlexalonNode node, Vector3 size, Vector3 min, Vector3 max)
    Parameters
    Type Name Description
    UnityEngine.Bounds componentBounds

    The bounds of the component.

    FlexalonNode node

    The node to measure the bounds for.

    UnityEngine.Vector3 size

    The size of the node.

    UnityEngine.Vector3 min

    The minimum size of the node.

    UnityEngine.Vector3 max

    The maximum size of the node.

    Returns
    Type Description
    UnityEngine.Bounds

    The bounds of the node.

    Mul(Vector3, Vector3)

    Multiplies each component of two vectors.

    Declaration
    public static Vector3 Mul(Vector3 a, Vector3 b)
    Parameters
    Type Name Description
    UnityEngine.Vector3 a

    The first vector.

    UnityEngine.Vector3 b

    The second vector.

    Returns
    Type Description
    UnityEngine.Vector3

    The multiplied vector.

    RotateBounds(Bounds, Quaternion)

    Rotates a bounds around the origin and returns a new bounds that encapsulates all of the rotated corners.

    Declaration
    public static Bounds RotateBounds(Bounds bounds, Quaternion rotation)
    Parameters
    Type Name Description
    UnityEngine.Bounds bounds

    The bounds to rotate.

    UnityEngine.Quaternion rotation

    The rotation to rotate the bounds by.

    Returns
    Type Description
    UnityEngine.Bounds

    The new bounds.

    ScaleBounds(Bounds, Vector3)

    Scales a bounds by multiplying the center and size by 'scale'.

    Declaration
    public static Bounds ScaleBounds(Bounds bounds, Vector3 scale)
    Parameters
    Type Name Description
    UnityEngine.Bounds bounds

    The bounds to scale.

    UnityEngine.Vector3 scale

    The scale to scale the bounds by.

    Returns
    Type Description
    UnityEngine.Bounds

    The scaled bounds.

    In This Article
    Back to top Flexalon 3D Layouts