2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-10-16 15:42:30 +02:00
|
|
|
title: Point.angle()
|
2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2021-10-16 15:42:30 +02:00
|
|
|
A point's `angle()` method returns the angle (in degrees) between this point and
|
|
|
|
the point passed into the method. An angle of 0° points to the right, and the angle increases counterclockwise.
|
|
|
|
|
2021-11-06 18:20:45 +01:00
|
|
|
## Point.angle() signature
|
|
|
|
|
2021-08-25 16:09:31 +02:00
|
|
|
```js
|
2021-11-06 18:20:45 +01:00
|
|
|
float point.angle(Point pointB)
|
2021-10-16 15:42:30 +02:00
|
|
|
```
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2021-11-06 18:20:45 +01:00
|
|
|
## Point.angle() Example
|
|
|
|
|
2022-01-19 11:31:39 +01:00
|
|
|
<Example part="point_angle">
|
|
|
|
An example of the Point.angle() method
|
|
|
|
</Example>
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
```js
|
|
|
|
let { Point, points, Path, paths } = part.shorthand();
|
|
|
|
|
|
|
|
points.sun = new Point(10, 5);
|
|
|
|
points.moon = points.sun.shift(-15, 70);
|
|
|
|
points.text = points.sun
|
|
|
|
.shiftFractionTowards(points.moon, 0.8)
|
|
|
|
.attr("data-text", points.sun.angle(points.moon)+"°")
|
|
|
|
.attr("data-text-class", "text-sm fill-note center");
|
|
|
|
|
|
|
|
paths.line = new Path()
|
|
|
|
.move(points.sun)
|
|
|
|
.line(points.moon)
|
|
|
|
.attr("class", "dashed");
|
|
|
|
```
|