.. role:: ts-api-decorator

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

.. container:: ts-api-section

   .. js:class:: Point2



.. container:: api-index-section

   .. rubric:: Constructors

   .. rst-class:: api-index-list-item api-kind-constructor api-parent-kind-class

   * :js:meth:`~Point2.constructor`



.. container:: api-index-section

   .. rubric:: Properties

   .. rst-class:: api-index-list-item api-kind-property api-parent-kind-class

   * :js:attr:`~Point2.x`
   * :js:attr:`~Point2.y`



.. container:: api-index-section

   .. rubric:: Methods

   .. rst-class:: api-index-list-item api-kind-method api-parent-kind-class

   * :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:`~Point2.distance`
   * :js:meth:`~Point2.fromJson`
   * :js:meth:`~Point2.fromPoint3`
   * :js:meth:`~Point2.zero`





------------

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

.. container:: ts-api-section

   .. js:function:: Point2.constructor( x, y)

      :param x: value to set for x
      :type x: number
      :param y: value to set for y
      :type y: number


      Creates a new point


      :rtype: Point2



Properties
==========

.. container:: ts-api-section

   .. js:attribute:: Point2.x

      :type: number





.. container:: ts-api-section

   .. js:attribute:: Point2.y

      :type: number





Methods
=======

.. rst-class:: ts-api-section

:ts-api-decorator:`static` add
------------------------------

.. js:method:: Point2.add( pt1, pt2)

   :param pt1: initial point
   :type pt1: Point2
   :param pt2: the point to add
   :type pt2: Point2


   Adds two points

   :returns: new point set to pt1 + pt2


   :rtype: Point2

.. rst-class:: ts-api-section

assign
------

.. js:method:: Point2.assign( pt)

   :param pt: the point whose values will be used to set this object
   :type pt: Point2


   Sets this point equal to another point

   :returns: the point object


   :rtype: this

.. rst-class:: ts-api-section

copy
----

.. js:method:: Point2.copy()



   Creates a copy of this point

   :returns: Copy of this point


   :rtype: Point2

.. rst-class:: ts-api-section

equals
------

.. js:method:: Point2.equals( pt)

   :param pt: the point to compare with
   :type pt: Point2


   Compares this point with another point

   :returns: True if the values of this point equal the other. False otherwise.


   :rtype: boolean

.. rst-class:: ts-api-section

length
------

.. js:method:: Point2.length()



   Returns the length of this point

   :returns: the point length


   :rtype: number

.. rst-class:: ts-api-section

:ts-api-decorator:`static` scale
--------------------------------

.. js:method:: Point2.scale( pt, k)

   :param pt: Point to be scaled
   :type pt: Point2
   :param k: Amount to scale by
   :type k: number


   Scale a point by a constant factor

   :returns: The scaled point


   :rtype: Point2

.. rst-class:: ts-api-section

set
---

.. js:method:: Point2.set( x, y)

   :param x: value to set for x
   :type x: number
   :param y: value to set for y
   :type y: number


   Sets the values of this point

   :returns: the point object


   :rtype: this

.. rst-class:: ts-api-section

squaredLength
-------------

.. js:method:: Point2.squaredLength()



   Returns the squared length of this vector.

   :returns: Vector squared length.


   :rtype: number

.. rst-class:: ts-api-section

:ts-api-decorator:`static` subtract
-----------------------------------

.. js:method:: Point2.subtract( pt1, pt2)

   :param pt1: initial point
   :type pt1: Point2
   :param pt2: the point to subtract
   :type pt2: Point2


   Subtracts a point from another

   :returns: new point set to pt1 - pt2


   :rtype: Point2

.. rst-class:: ts-api-section

toJson
------

.. js:method:: Point2.toJson()



   Creates an object ready for JSON serialization.

   :returns: The prepared object.


   :rtype: IPoint2

.. rst-class:: ts-api-section

:ts-api-decorator:`static` distance
-----------------------------------

.. js:method:: Point2.distance( p1, p2)

   :param p1: first point
   :type p1: Point2
   :param p2: second point
   :type p2: Point2


   Calculate distance between two points

   :returns: the distance between p1 and p2


   :rtype: number

.. rst-class:: ts-api-section

:ts-api-decorator:`static` fromJson
-----------------------------------

.. js:method:: Point2.fromJson( objData)

   :param objData: An object given by [[toJson]].
   :type objData: unknown


   Creates a new [[Point2]] from an object given by [[toJson]].

   :returns: The prepared object.


   :rtype: Point2

.. rst-class:: ts-api-section

:ts-api-decorator:`static` fromPoint3
-------------------------------------

.. js:method:: Point2.fromPoint3( p)

   :param p: None
   :type p: IPoint3


   :rtype: Point2

.. rst-class:: ts-api-section

:ts-api-decorator:`static` zero
-------------------------------

.. js:method:: Point2.zero()



   Creates a point initialized to (0,0)

   :returns: The new point


   :rtype: Point2

