Home Reference Source Test Repository
public class | source

Point2D

Class representing 2D points.

Test:

Constructor Summary

Public Constructor
public

Constructs a Point2D object.

Member Summary

Public Members
public

x: *

public

y: *

Method Summary

Public Methods
public

Finds the distance between this point and another point.

public

Checks if this point and another point are equal.

public

lineTo(point: Point2D): Line2D

Creates and returns a Line2D object using this point as the start point and another point as the end point.

public

Finds the coordinates this point should have relative to a triangle.

public

Translates the point using a vector.

public

Finds the vector distance from this point to another point.

Public Constructors

public constructor(x: number, y: number) source

Constructs a Point2D object.

Params:

NameTypeAttributeDescription
x number

x-coordinate of the point.

y number

y-coordinate of the point.

Test:

Public Members

public x: * source

public y: * source

Public Methods

public distanceTo(point: Point2D): number source

Finds the distance between this point and another point.

Params:

NameTypeAttributeDescription
point Point2D

Point to find the distance to.

Return:

number

Distance between the points.

Test:

public equals(point: Point2D): boolean source

Checks if this point and another point are equal. Returns true if the x- and y-coordinates are equal.

Params:

NameTypeAttributeDescription
point Point2D

Point to compare with.

Return:

boolean

Whether or not the points are equivalent.

Test:

public lineTo(point: Point2D): Line2D source

Creates and returns a Line2D object using this point as the start point and another point as the end point.

Params:

NameTypeAttributeDescription
point Point2D

Point to be used as the end point.

Return:

Line2D

Line2D object created.

Test:

public relativePositionToTriangle2D(oldTriangle: Triangle2D, newTriangle: Triangle2D): Point2D source

Finds the coordinates this point should have relative to a triangle.

Params:

NameTypeAttributeDescription
oldTriangle Triangle2D

Triangle2D object containing the triangle's old position.

newTriangle Triangle2D

Triangle2D object containing the triangle's new position.

Return:

Point2D

Point representing the point's location relative the the triangle's new position.

Test:

public translateVec(vec: Vector2D): Point2D source

Translates the point using a vector.

Params:

NameTypeAttributeDescription
vec Vector2D

The vector to translate the point by.

Return:

Point2D

Point resulting from the translation.

Test:

public vectorTo(point: Point2D): Vector2D source

Finds the vector distance from this point to another point.

Params:

NameTypeAttributeDescription
point Point2D

Point to find the vector distance to.

Return:

Vector2D

Vector2D object representing the vector distance.

Test: