2023-04-10 16:15:52 +00:00
|
|
|
---
|
|
|
|
title: Point.slope()
|
|
|
|
---
|
|
|
|
|
2023-04-16 16:39:13 +00:00
|
|
|
The `Point.slope()` method returns the slope of a line made by this Point and that Point.
|
2023-04-10 16:15:52 +00:00
|
|
|
|
|
|
|
## Signature
|
|
|
|
|
|
|
|
```js
|
2023-04-16 16:39:13 +00:00
|
|
|
|
|
|
|
point.slope(otherPoint)
|
|
|
|
|
2023-04-10 16:15:52 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## Example
|
|
|
|
|
|
|
|
<Example caption="An example of the Point.slope() method">
|
2023-04-16 16:39:13 +00:00
|
|
|
|
2023-04-10 16:15:52 +00:00
|
|
|
```js
|
2023-04-16 16:39:13 +00:00
|
|
|
|
2023-04-10 16:15:52 +00:00
|
|
|
({ Point, points, Path, paths, Snippet, snippets, part }) => {
|
|
|
|
|
2023-04-16 16:39:13 +00:00
|
|
|
points.A = new Point(0,0)
|
|
|
|
points.B = new Point(40,30)
|
|
|
|
|
|
|
|
const slope = points.A.slope(points.B)
|
|
|
|
|
|
|
|
paths.line = new Path()
|
|
|
|
.move(points.A)
|
|
|
|
.line(points.B)
|
|
|
|
.attr("class", "canvas")
|
|
|
|
.setText("Slope: " + slope, "text-xs center")
|
2023-04-10 16:15:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return part
|
|
|
|
}
|
2023-04-16 16:39:13 +00:00
|
|
|
|
2023-04-10 16:15:52 +00:00
|
|
|
```
|
|
|
|
</Example>
|
|
|
|
|
|
|
|
|