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


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

.. js:class:: common.Point2

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



.. rst-class:: kind-group kind-constructors

.. rubric:: Constructors
   :class: kind-group-title


.. js:method:: common.Point2.constructor

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



.. rst-class:: kind-group kind-properties

.. rubric:: Properties
   :class: kind-group-title


.. js:data:: common.Point2.x

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



.. js:data:: common.Point2.y

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



.. rst-class:: kind-group kind-methods

.. rubric:: Methods
   :class: kind-group-title


.. js:method:: static common.Point2.add

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



.. js:method:: static common.Point2.distance

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



.. js:method:: static common.Point2.fromJson

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



.. js:method:: static common.Point2.fromPoint3

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



.. js:method:: static common.Point2.scale

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



.. js:method:: static common.Point2.subtract

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



.. js:method:: static common.Point2.zero

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



.. js:method:: common.Point2.add

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



.. js:method:: common.Point2.assign

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



.. js:method:: common.Point2.copy

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



.. js:method:: common.Point2.equals

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



.. js:method:: common.Point2.length

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



.. js:method:: common.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:: common.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:: common.Point2.squaredLength

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



.. js:method:: common.Point2.subtract

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



.. js:method:: common.Point2.toJson

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




