.. role:: clio-static
   :class: clio-flag clio-flag-static


######
Point2
######

.. js:class:: Point2

   
   Index
   =====
   
   .. rubric:: Constructors
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:func:`~Point2.constructor`
   
   .. rubric:: Properties
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:data:`~Point2.x`
   * :js:data:`~Point2.y`
   
   .. rubric:: Methods
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:meth:`~Point2.add`
   * :js:meth:`~Point2.assign`
   * :js:meth:`~Point2.copy`
   * :js:meth:`~Point2.equals`
   * :js:meth:`~Point2.length`
   * :js:meth:`~Point2.scale`
   * :js:meth:`~Point2.set`
   * :js:meth:`~Point2.squaredLength`
   * :js:meth:`~Point2.subtract`
   * :js:meth:`~Point2.toJson`
   * :js:meth:`~static Point2.add`
   * :js:meth:`~static Point2.distance`
   * :js:meth:`~static Point2.fromJson`
   * :js:meth:`~static Point2.fromPoint3`
   * :js:meth:`~static Point2.scale`
   * :js:meth:`~static Point2.subtract`
   * :js:meth:`~static Point2.zero`
   
   




Constructors
============

.. js:method:: Point2.constructor

   .. rst-class:: sig-pretty-signature
   
      | Point2(**x**\ : *number*\ , **y**\ : *number*\ ): :js:class:`~Point2`
   
   Creates a new point
   
   **Parameters**
   
      **x**\ : *number*
   
         value to set for x
   
   
      **y**\ : *number*
   
         value to set for y
   
   
   
   **Returns**\ : :js:class:`~Point2`
   





Properties
==========

.. js:data:: Point2.x

   .. rst-class:: sig-pretty-signature
   
      | x: *number*
   



.. js:data:: Point2.y

   .. rst-class:: sig-pretty-signature
   
      | y: *number*
   





Methods
=======

.. js:method:: Point2.add

   .. rst-class:: sig-pretty-signature
   
      | add(**pt**\ : :js:class:`~Point2`\ ): *this*
   
   Adds a point to this one
   
   **Parameters**
   
      **pt**\ : :js:class:`~Point2`
   
         the point whose values will be added
   
   
   
   **Returns**\ : *this*
   
      the point object
   
   



.. js:method:: Point2.assign

   .. rst-class:: sig-pretty-signature
   
      | assign(**pt**\ : :js:class:`~Point2`\ ): *this*
   
   Sets this point equal to another point
   
   **Parameters**
   
      **pt**\ : :js:class:`~Point2`
   
         the point whose values will be used to set this object
   
   
   
   **Returns**\ : *this*
   
      the point object
   
   



.. js:method:: Point2.copy

   .. rst-class:: sig-pretty-signature
   
      | copy(): :js:class:`~Point2`
   
   Creates a copy of this point
   
   **Returns**\ : :js:class:`~Point2`
   
      Copy of this point
   
   



.. js:method:: Point2.equals

   .. rst-class:: sig-pretty-signature
   
      | equals(**pt**\ : :js:class:`~Point2`\ ): *boolean*
   
   Compares this point with another point
   
   **Parameters**
   
      **pt**\ : :js:class:`~Point2`
   
         the point to compare with
   
   
   
   **Returns**\ : *boolean*
   
      True if the values of this point equal the other. False otherwise.
   
   



.. js:method:: Point2.length

   .. rst-class:: sig-pretty-signature
   
      | length(): *number*
   
   Returns the length of this point
   
   **Returns**\ : *number*
   
      the point length
   
   



.. js:method:: Point2.scale

   .. rst-class:: sig-pretty-signature
   
      | scale(**k**\ : *number*\ ): *this*
   
   Scales the point by a constant value
   
   **Parameters**
   
      **k**\ : *number*
   
         the value to scale by
   
   
   
   **Returns**\ : *this*
   
      the point object
   
   



.. js:method:: Point2.set

   .. rst-class:: sig-pretty-signature
   
      | set(**x**\ : *number*\ , **y**\ : *number*\ ): *this*
   
   Sets the values of this point
   
   **Parameters**
   
      **x**\ : *number*
   
         value to set for x
   
   
      **y**\ : *number*
   
         value to set for y
   
   
   
   **Returns**\ : *this*
   
      the point object
   
   



.. js:method:: Point2.squaredLength

   .. rst-class:: sig-pretty-signature
   
      | squaredLength(): *number*
   
   Returns the squared length of this vector.
   
   **Returns**\ : *number*
   
      Vector squared length.
   
   



.. js:method:: Point2.subtract

   .. rst-class:: sig-pretty-signature
   
      | subtract(**pt**\ : :js:class:`~Point2`\ ): *this*
   
   Subtracts a point from this one
   
   **Parameters**
   
      **pt**\ : :js:class:`~Point2`
   
         the point whose values will be subtracted
   
   
   
   **Returns**\ : *this*
   
      the point object
   
   



.. js:method:: Point2.toJson

   .. rst-class:: sig-pretty-signature
   
      | toJson(): :js:class:`~IPoint2`
   
   Creates an object ready for JSON serialization.
   
   **Returns**\ : :js:class:`~IPoint2`
   
      The prepared object.
   
   



.. js:method:: static Point2.add

   .. rst-class:: clio-flags
   
      :clio-static:`static`
   
   .. rst-class:: sig-pretty-signature
   
      | add(**pt1**\ : :js:class:`~Point2`\ , **pt2**\ : :js:class:`~Point2`\ ): :js:class:`~Point2`
   
   Adds two points
   
   **Parameters**
   
      **pt1**\ : :js:class:`~Point2`
   
         initial point
   
   
      **pt2**\ : :js:class:`~Point2`
   
         the point to add
   
   
   
   **Returns**\ : :js:class:`~Point2`
   
      new point set to pt1 + pt2
   
   



.. js:method:: static Point2.distance

   .. rst-class:: clio-flags
   
      :clio-static:`static`
   
   .. rst-class:: sig-pretty-signature
   
      | distance(**p1**\ : :js:class:`~Point2`\ , **p2**\ : :js:class:`~Point2`\ ): *number*
   
   Calculate distance between two points
   
   **Parameters**
   
      **p1**\ : :js:class:`~Point2`
   
         first point
   
   
      **p2**\ : :js:class:`~Point2`
   
         second point
   
   
   
   **Returns**\ : *number*
   
      the distance between p1 and p2
   
   



.. js:method:: static Point2.fromJson

   .. rst-class:: clio-flags
   
      :clio-static:`static`
   
   .. rst-class:: sig-pretty-signature
   
      | fromJson(**objData**\ : *unknown*\ ): :js:class:`~Point2`
   
   Creates a new [[Point2]] from an object given by [[toJson]].
   
   **Parameters**
   
      **objData**\ : *unknown*
   
         An object given by [[toJson]].
   
   
   
   **Returns**\ : :js:class:`~Point2`
   
      The prepared object.
   
   



.. js:method:: static Point2.fromPoint3

   .. rst-class:: clio-flags
   
      :clio-static:`static`
   
   .. rst-class:: sig-pretty-signature
   
      | fromPoint3(**p**\ : :js:class:`~IPoint3`\ ): :js:class:`~Point2`
   
   **Parameters**
   
      **p**\ : :js:class:`~IPoint3`
   
   
   **Returns**\ : :js:class:`~Point2`
   



.. js:method:: static Point2.scale

   .. rst-class:: clio-flags
   
      :clio-static:`static`
   
   .. rst-class:: sig-pretty-signature
   
      | scale(**pt**\ : :js:class:`~Point2`\ , **k**\ : *number*\ ): :js:class:`~Point2`
   
   Scale a point by a constant factor
   
   **Parameters**
   
      **pt**\ : :js:class:`~Point2`
   
         Point to be scaled
   
   
      **k**\ : *number*
   
         Amount to scale by
   
   
   
   **Returns**\ : :js:class:`~Point2`
   
      The scaled point
   
   



.. js:method:: static Point2.subtract

   .. rst-class:: clio-flags
   
      :clio-static:`static`
   
   .. rst-class:: sig-pretty-signature
   
      | subtract(**pt1**\ : :js:class:`~Point2`\ , **pt2**\ : :js:class:`~Point2`\ ): :js:class:`~Point2`
   
   Subtracts a point from another
   
   **Parameters**
   
      **pt1**\ : :js:class:`~Point2`
   
         initial point
   
   
      **pt2**\ : :js:class:`~Point2`
   
         the point to subtract
   
   
   
   **Returns**\ : :js:class:`~Point2`
   
      new point set to pt1 - pt2
   
   



.. js:method:: static Point2.zero

   .. rst-class:: clio-flags
   
      :clio-static:`static`
   
   .. rst-class:: sig-pretty-signature
   
      | zero(): :js:class:`~Point2`
   
   Creates a point initialized to (0,0)
   
   **Returns**\ : :js:class:`~Point2`
   
      The new point
   
   





