Point.js

  • Point()

    Point's constructor

  • toString()

    Converts the current instance to a string
    Ex.: Point(12.05,15.17)

  • clone()

    Creates a copy of the current instance

  • add()

    Adds the given point's values to the current instance without modifying the current instance

  • substract()

    Substracts the given point's values from the current instance without modifying the current instance

  • multiplyBy()

    Multiplies the values of the current instance by the given point's values or by just a number without modifying the current instance

  • divideBy()

    Divides the values of the current instance by the given point's values or by just a number without modifying the current instance

  • round()

    Rounds the values of the current instance to the closest integer without modifying the current instance

  • floor()

    Rounds the values of the current instance to the largest previous integer without modifying the current instance

  • isEqual()

    Compares the values of the current instance with another's

  • distanceTo()

    Calculates the distance between the current point and another

Point()


constructor

Point class is used to define a geometric point

Parameter Type Description
x Number The x property of the point
y Number The y property of the point

toString()


method

Converts the current instance to a string
Ex.: Point(12.05,15.17)

returns
String - The converted string

clone()


method

Creates a copy of the current instance

returns
Point - point The copy of the current instance

add()


method

Adds the given point's values to the current instance without modifying the current instance

Parameter Type Description
point Point The point whose values will be added
returns
Point - The new point

substract()


method

Substracts the given point's values from the current instance without modifying the current instance

Parameter Type Description
point Point The point whose values will be substracted
returns
Point - The new point

multiplyBy()


method

Multiplies the values of the current instance by the given point's values or by just a number without modifying the current instance

Parameter Type Description
val Point | Number The point or the number whose values will be multiplied
returns
Point - The new point

divideBy()


method

Divides the values of the current instance by the given point's values or by just a number without modifying the current instance

Parameter Type Description
val Point | Number The point or the number whose value will be the divisor
returns
Point - The new point

round()


method

Rounds the values of the current instance to the closest integer without modifying the current instance

returns
Point - The new point

floor()


method

Rounds the values of the current instance to the largest previous integer without modifying the current instance

returns
Point - The new point

isEqual()


method

Compares the values of the current instance with another's

Parameter Type Description
other Point The point with which the comparison is done
tollerance Number If specified checks quality considering the tollerance.
returns
Boolean - If true, the values are equal

distanceTo()


method

Calculates the distance between the current point and another

Parameter Type Description
other Point The point to which the distance will be calculated
returns
Number - The calculated distance