Provides static functions to make Polygons of various shapes.

Properties

BOTTOM_EDGE: 0 = 0

index of bottom edge in Polygon from makeBlock()

ID: number = 1

Counter used for naming shapes.

LEFT_EDGE: 3 = 3

index of left edge in Polygon from makeBlock()

RIGHT_EDGE: 1 = 1

index of right edge in Polygon from makeBlock()

TOP_EDGE: 2 = 2

index of top edge in Polygon from makeBlock()

Methods

  • Makes a circular Polygon with given radius.

    Parameters

    • radius: number

      radius of the circle

    • Optional opt_name: string

      name of the Polygon

    • Optional opt_localName: string

      localized name of the Polygon

    Returns Polygon

    a circular Polygon

  • Makes a rectangular Polygon with given width and height; in body coords the center is at the origin, and width is along the x-axis, height along the y-axis.

    Parameters

    • width: number

      width of the block, horizontal dimension in body orientation

    • height: number

      height of the block, vertical dimension in body orientation

    • Optional opt_name: string

      name of the Polygon

    • Optional opt_localName: string

      localized name of the Polygon

    Returns Polygon

    a rectangular Polygon

  • Makes a rectangular Polygon with given width and height; in body coords the origin is at the bottom left corner.

    Parameters

    • width: number

      width of the block, horizontal dimension in body orientation

    • height: number

      height of the block, vertical dimension in body orientation

    • Optional opt_name: string

      name of the Polygon

    • Optional opt_localName: string

      localized name of the Polygon

    Returns Polygon

    a rectangular Polygon

  • Returns a rectangle centered at origin with the given width and height, but rotated by the given angle in the body coordinate system. The purpose is to ensure that angled straight lines are tested.

    Parameters

    • width: number

      width in unrotated position

    • height: number

      height in unrotated position

    • angle: number

      angle to rotate by in radians, must be between +/- PI/2

    • Optional opt_name: string

      name of the Polygon

    • Optional opt_localName: string

      localized name of the Polygon

    Returns Polygon

    a rectangle centered at origin with the given width and height, but rotated by the given angle

  • Makes a hollow box or 'square doughnut' shape.

    Parameters

    • width: number

      width of frame, measured to center of walls

    • height: number

      height of frame, measured to center of walls

    • thickness: number

      thickness of walls

    • Optional opt_name: string

      name of the Polygon

    • Optional opt_localName: string

      localized name of the Polygon

    Returns Polygon

  • Makes a regular hexagon with edges of given size.

    Parameters

    • size: number

      length of edge of hexagon

    • Optional opt_name: string

      name of the Polygon

    • Optional opt_localName: string

      localized name of the Polygon

    Returns Polygon

    a regular hexagon

  • Creates a pendulum shaped Polygon: a circle with a long stick attached. The center of mass and drag point is at the center of the circle. In body coordinates, the center of the circle is at the origin and the stick is straight above.

    Parameters

    • width: number

      width of the stick

    • length: number

      length of the stick

    • radius: number

      radius of the circle

    • Optional opt_name: string

      name of the Polygon

    • Optional opt_localName: string

      localized name of the Polygon

    Returns Polygon

    a pendulum-shaped Polygon

  • Creates a Polygon whose vertices are at the given points.

    Parameters

    • points: Vector[]

      array of points giving location of vertices in body coordinates

    • outIsUp: boolean[]

      the value of outsideIsUp for each edge

    • moment: number

      moment about center of mass

    • Optional opt_name: string

      name of the Polygon

    • Optional opt_localName: string

      localized name of the Polygon

    Returns Polygon

    Polygon whose vertices are at the given points

  • Creates a randomly shaped polygon with given number of sides. The corners lie on a circle with given radius centered at origin.

    Parameters

    • sides: number

      number of sides, minumum is 3

    • radius: number

      radius of circle that the Polygon fits inside of

    • Optional minAngle: number

      the minimum distance between corners on the circle in radians

    • Optional maxAngle: number

      the maximum distance between corners on the circle in radians

    • Optional opt_name: string

      name of the Polygon

    • Optional opt_localName: string

      localized name of the Polygon

    Returns Polygon

    a block with round corners

  • Creates a block with rounded ends. Height must be greater than width.

    Parameters

    • width: number

      width in unrotated position

    • height: number

      height in unrotated position

    • Optional opt_name: string

      name of the Polygon

    • Optional opt_localName: string

      localized name of the Polygon

    Returns Polygon

    a block with rounded ends

  • Creates a rectangular block with small round corners. In body coords the center is at the origin, and width is along the x-axis, height along the y-axis.

    Parameters

    • width: number

      width of the block

    • height: number

      height of the block

    • radius: number

      radius of each corner

    • Optional opt_name: string

      name of the Polygon

    • Optional opt_localName: string

      localized name of the Polygon

    Returns Polygon

    a block with round corners

  • Makes a rectangular Polygon with a special edge that causes special proximity testing to be done for this Polygon. The other edges of this Polygon are given zero centroid radius, so that they are effectively never used for collision testing. See Polygon.getSpecialNormalWorld.

    Parameters

    • width: number

      width of the wall, horizontal dimension in body orientation

    • height: number

      height of the wall, vertical dimension in body orientation

    • edgeIndex: number

      index of the special edge: use the constants BOTTOM_EDGE, LEFT_EDGE, RIGHT_EDGE, TOP_EDGE

    • Optional opt_name: string

      name of the Polygon

    • Optional opt_localName: string

      localized name of the Polygon

    Returns Polygon

    a rectangular Polygon with a special edge

Generated using TypeDoc