mirror of
https://git.leinelab.org/Mal/mr-crocs-adventures.git
synced 2025-09-11 02:57:36 +02:00
Init
This commit is contained in:
30
js/geometry/GeometryPoint.js
Normal file
30
js/geometry/GeometryPoint.js
Normal file
@@ -0,0 +1,30 @@
|
||||
export default class GeometryPoint
|
||||
{
|
||||
constructor(x, y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
isEqual(geometryPoint)
|
||||
{
|
||||
return this.x === geometryPoint.x && this.y === geometryPoint.y;
|
||||
}
|
||||
|
||||
getDistanceToPoint(geometryPoint)
|
||||
{
|
||||
return Math.sqrt(Math.pow(geometryPoint.x - this.x,2) + Math.pow(geometryPoint.y - this.y,2));
|
||||
}
|
||||
|
||||
getAngleToPoint(geometryPoint)
|
||||
{
|
||||
return Math.atan2(this.y - geometryPoint.y, this.x - geometryPoint.x);
|
||||
}
|
||||
|
||||
draw(context)
|
||||
{
|
||||
context.beginPath();
|
||||
context.arc(this.x, this.y, 3, 0, 2 * Math.PI);
|
||||
context.stroke();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user