Circle
Module Geometry.Circles
In ixfx, a circle is simply an object with radius
, or if it’s positioned it also has coordinates:
type Circle = { radius:number}type CirclePositioned = { radius:number x:number y:number}
Once you have that there are a bunch of functions to help you work with circles.
- area - compute area
- bbox - compute bounding box
- center - compute center
- circumference - (aka ‘length’)
- distanceCenter - distance between two circle centers
- distanceFromExterior - distance between outer edge of two circles
- interpolate - compute relative position along circumference
- intersectionLine - point(s) of intersection between a circle and line
- intersections - points of intersections between two circles
- isContainedBy - check if one circle contains another circle or point
- isIntersecting - check if one circle intersects with another circle or point
- nearest - compute nearest point on circle’s perimeter to a given point
- pointOnPerimeter - get point on perimeter at specified angle
- randomPoint - get a random point within circle
Importing
// Sub moduleimport { Circles } from "@ixfx/geometry.js"// Eg: Circles.nearest();
// Whole moduleimport * as Geometry from "@ixfx/geometry.js"// Eg: Geometry.Circles.nearest();
// From bundleimport { Geometry } from "@ixfx/bundle.js"// Eg: Geometry.Circles.nearest();
// And within your HTML's <HEAD> </HEAD> block:<script type="importmap">{ "imports": { "@ixfx/": "/ixfx/" } }</script>
// Sub module from parentimport { Circles } from "@ixfx/geometry.js"// Eg: Circles.nearest();
// Whole parent moduleimport * as Geometry from "@ixfx/geometry.js"// Eg: Geometry.Circles.nearest();
// From the bundleimport { Geometry } from "@ixfx/bundle.js"// Eg: Geometry.Circles.nearest();
// Sub module from parentimport { Circles } from "https://unpkg.com/@ixfx/geometry/bundle"// Eg: Circles.nearest();
// Whole parent moduleimport * as Geometry from "https://unpkg.com/@ixfx/geometry/bundle"// Eg: Geometry.Circles.nearest();
// Single module from the bundleimport { Geometry } from "https://unpkg.com/@ixfx/bundle"// Eg: Geometry.Circles.nearest();