Skip to content
0

katanakit-js / GeometryUtils

Variable: GeometryUtils ​

ts
const GeometryUtils: {
  area: {
     useCircle: string;
     useEllipse: string;
     useHexagon: string;
     useParallelogram: string;
     useRectangle: string;
     useSquare: string;
     useTrapezoid: string;
     useTriangle: string;
  };
  perimeter: {
     useCircle: string;
     useEllipse: string;
     useHexagon: string;
     useParallelogram: string;
     useRectangle: string;
     useSquare: string;
     useTrapezoid: string;
     useTriangle: string;
  };
  volume: {
     useBox: string;
     useCone: string;
     useCube: string;
     useCylinder: string;
     usePyramid: string;
     useSphere: string;
  };
};

Defined in: src/core/services/geometry.service.ts:490

Consolidated pure geometry utilities namespace. Groups area, perimeter and volume calculations (no shared mutable state).

Type Declaration ​

area ​

ts
area: {
  useCircle: string;
  useEllipse: string;
  useHexagon: string;
  useParallelogram: string;
  useRectangle: string;
  useSquare: string;
  useTrapezoid: string;
  useTriangle: string;
};

Pure area calculations for geometric shapes. All functions are stateless — input → formatted string only.

Type Declaration ​

area.useCircle() ​

ts
useCircle(radius, options?): string;

Calculates the area of a circle.

Parameters ​
ParameterTypeDescription
radiusnumberThe radius of the circle.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted area string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.area.useCircle(5); // "78.54"

area.useEllipse() ​

ts
useEllipse(
   semiMajor, 
   semiMinor, 
   options?
): string;

Calculates the area of an ellipse.

Parameters ​
ParameterTypeDescription
semiMajornumberThe semi-major axis length.
semiMinornumberThe semi-minor axis length.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted area string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.area.useEllipse(5, 3); // "47.12"

area.useHexagon() ​

ts
useHexagon(side, options?): string;

Calculates the area of a regular hexagon.

Parameters ​
ParameterTypeDescription
sidenumberThe side length of the hexagon.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted area string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.area.useHexagon(3); // "23.38"

area.useParallelogram() ​

ts
useParallelogram(
   base, 
   height, 
   options?
): string;

Calculates the area of a parallelogram.

Parameters ​
ParameterTypeDescription
basenumberThe base length of the parallelogram.
heightnumberThe height of the parallelogram.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted area string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.area.useParallelogram(6, 4); // "24.00"

area.useRectangle() ​

ts
useRectangle(
   width, 
   height, 
   options?
): string;

Calculates the area of a rectangle.

Parameters ​
ParameterTypeDescription
widthnumberThe width of the rectangle.
heightnumberThe height of the rectangle.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted area string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.area.useRectangle(5, 10); // "50.00"
GeometryUtils.area.useRectangle(5, 10, { unit: "m²" }); // "50.00 m²"

area.useSquare() ​

ts
useSquare(side, options?): string;

Calculates the area of a square.

Parameters ​
ParameterTypeDescription
sidenumberThe side length of the square.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted area string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.area.useSquare(4); // "16.00"

area.useTrapezoid() ​

ts
useTrapezoid(
   parallelSide1, 
   parallelSide2, 
   height, 
   options?
): string;

Calculates the area of a trapezoid.

Parameters ​
ParameterTypeDescription
parallelSide1numberThe length of the first parallel side.
parallelSide2numberThe length of the second parallel side.
heightnumberThe height between parallel sides.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted area string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.area.useTrapezoid(3, 5, 4); // "16.00"

area.useTriangle() ​

ts
useTriangle(
   base, 
   height, 
   options?
): string;

Calculates the area of a triangle.

Parameters ​
ParameterTypeDescription
basenumberThe base length of the triangle.
heightnumberThe height of the triangle.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted area string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.area.useTriangle(6, 4); // "12.00"

perimeter ​

ts
perimeter: {
  useCircle: string;
  useEllipse: string;
  useHexagon: string;
  useParallelogram: string;
  useRectangle: string;
  useSquare: string;
  useTrapezoid: string;
  useTriangle: string;
};

Pure perimeter calculations for geometric shapes. All functions are stateless — input → formatted string only.

Type Declaration ​

perimeter.useCircle() ​

ts
useCircle(radius, options?): string;

Calculates the perimeter (circumference) of a circle.

Parameters ​
ParameterTypeDescription
radiusnumberThe radius of the circle.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted perimeter string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.perimeter.useCircle(5); // "31.42"

perimeter.useEllipse() ​

ts
useEllipse(
   semiMajor, 
   semiMinor, 
   options?
): string;

Calculates the perimeter of an ellipse using Ramanujan's approximation II.

Parameters ​
ParameterTypeDescription
semiMajornumberThe semi-major axis length.
semiMinornumberThe semi-minor axis length.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted perimeter string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.perimeter.useEllipse(5, 3); // "25.53"

perimeter.useHexagon() ​

ts
useHexagon(side, options?): string;

Calculates the perimeter of a regular hexagon.

Parameters ​
ParameterTypeDescription
sidenumberThe side length of the hexagon.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted perimeter string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.perimeter.useHexagon(3); // "18.00"

perimeter.useParallelogram() ​

ts
useParallelogram(
   side1, 
   side2, 
   options?
): string;

Calculates the perimeter of a parallelogram.

Parameters ​
ParameterTypeDescription
side1numberThe length of the first side.
side2numberThe length of the second side.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted perimeter string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.perimeter.useParallelogram(5, 3); // "16.00"

perimeter.useRectangle() ​

ts
useRectangle(
   width, 
   height, 
   options?
): string;

Calculates the perimeter of a rectangle.

Parameters ​
ParameterTypeDescription
widthnumberThe width of the rectangle.
heightnumberThe height of the rectangle.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted perimeter string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.perimeter.useRectangle(5, 10); // "30.00"
GeometryUtils.perimeter.useRectangle(5, 10, { unit: "m" }); // "30.00 m"

perimeter.useSquare() ​

ts
useSquare(side, options?): string;

Calculates the perimeter of a square.

Parameters ​
ParameterTypeDescription
sidenumberThe side length of the square.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted perimeter string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.perimeter.useSquare(4); // "16.00"

perimeter.useTrapezoid() ​

ts
useTrapezoid(
   side1, 
   side2, 
   side3, 
   side4, 
   options?
): string;

Calculates the perimeter of a trapezoid.

Parameters ​
ParameterTypeDescription
side1numberThe length of the first side.
side2numberThe length of the second side.
side3numberThe length of the third side.
side4numberThe length of the fourth side.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted perimeter string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.perimeter.useTrapezoid(3, 5, 4, 4); // "16.00"

perimeter.useTriangle() ​

ts
useTriangle(
   side1, 
   side2, 
   side3, 
   options?
): string;

Calculates the perimeter of a triangle.

Parameters ​
ParameterTypeDescription
side1numberThe length of the first side.
side2numberThe length of the second side.
side3numberThe length of the third side.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted perimeter string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.perimeter.useTriangle(3, 4, 5); // "12.00"

volume ​

ts
volume: {
  useBox: string;
  useCone: string;
  useCube: string;
  useCylinder: string;
  usePyramid: string;
  useSphere: string;
};

Pure volume calculations for 3D geometric shapes. All functions are stateless — input → formatted string only.

Type Declaration ​

volume.useBox() ​

ts
useBox(
   length, 
   width, 
   height, 
   options?
): string;

Calculates the volume of a box (rectangular prism).

Parameters ​
ParameterTypeDescription
lengthnumberThe length of the box.
widthnumberThe width of the box.
heightnumberThe height of the box.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted volume string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.volume.useBox(2, 3, 4); // "24.00"

volume.useCone() ​

ts
useCone(
   radius, 
   height, 
   options?
): string;

Calculates the volume of a cone.

Parameters ​
ParameterTypeDescription
radiusnumberThe radius of the cone base.
heightnumberThe height of the cone.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted volume string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.volume.useCone(3, 5); // "47.12"

volume.useCube() ​

ts
useCube(side, options?): string;

Calculates the volume of a cube.

Parameters ​
ParameterTypeDescription
sidenumberThe side length of the cube.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted volume string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.volume.useCube(3); // "27.00"
GeometryUtils.volume.useCube(3, { unit: "m³" }); // "27.00 m³"

volume.useCylinder() ​

ts
useCylinder(
   radius, 
   height, 
   options?
): string;

Calculates the volume of a cylinder.

Parameters ​
ParameterTypeDescription
radiusnumberThe radius of the cylinder base.
heightnumberThe height of the cylinder.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted volume string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.volume.useCylinder(3, 5); // "141.37"

volume.usePyramid() ​

ts
usePyramid(
   baseArea, 
   height, 
   options?
): string;

Calculates the volume of a pyramid.

Parameters ​
ParameterTypeDescription
baseAreanumberThe area of the pyramid base.
heightnumberThe height of the pyramid.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted volume string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.volume.usePyramid(12, 5); // "20.00"

volume.useSphere() ​

ts
useSphere(radius, options?): string;

Calculates the volume of a sphere.

Parameters ​
ParameterTypeDescription
radiusnumberThe radius of the sphere.
options?{ digits?: number; locale?: string; unit?: string; }Optional formatting options.
options.digits?number-
options.locale?string-
options.unit?string-
Returns ​

string

The formatted volume string.

Example ​
ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.volume.useSphere(3); // "113.10"

Example ​

ts
import { GeometryUtils } from "katanakit-js";

GeometryUtils.area.useCircle(5);       // "78.54"
GeometryUtils.perimeter.useCircle(5);  // "31.42"
GeometryUtils.volume.useSphere(3);     // "113.10"

Released under the MIT License.