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
|
|
|
|
2022-09-27 19:15:57 +02:00
|
|
|
The `Point.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-10-16 15:42:30 +02:00
|
|
|
|
2022-09-27 19:15:57 +02:00
|
|
|
## Signature
|
2021-11-06 18:20:45 +01:00
|
|
|
|
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
|
|
|
|
2022-09-27 19:15:57 +02:00
|
|
|
## Example
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-27 19:15:57 +02:00
|
|
|
<Example caption="An example of the Point.angle() method">
|
2021-08-25 16:09:31 +02:00
|
|
|
```js
|
2022-09-27 19:15:57 +02:00
|
|
|
({ Point, points, Path, paths, part }) => {
|
|
|
|
|
2022-09-29 16:50:42 +02:00
|
|
|
points.sun = new Point(10, 5)
|
|
|
|
points.moon = points.sun.shift(-15, 70)
|
2022-09-27 19:15:57 +02:00
|
|
|
points.text = points.sun
|
|
|
|
.shiftFractionTowards(points.moon, 0.8)
|
2022-09-29 16:50:42 +02:00
|
|
|
.setText(
|
|
|
|
points.sun.angle(points.moon)+"°",
|
|
|
|
"text-sm fill-note center"
|
2022-12-30 07:47:29 -08:00
|
|
|
)
|
|
|
|
|
2022-09-27 19:15:57 +02:00
|
|
|
paths.line = new Path()
|
|
|
|
.move(points.sun)
|
|
|
|
.line(points.moon)
|
2022-09-29 16:50:42 +02:00
|
|
|
.setClass("dashed")
|
2022-09-27 19:15:57 +02:00
|
|
|
|
|
|
|
return part
|
|
|
|
}
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|
2022-09-27 19:15:57 +02:00
|
|
|
</Example>
|