Skip to content

GeometricUtils

Aram edited this page Jan 9, 2025 · 2 revisions

GeometricUtils

Overview

The GeometricUtils class in the software.bluelib.utils.math package provides utility methods for various geometric calculations. This utility class includes methods to compute distances, areas, volumes, and perimeters for basic geometric shapes such as circles, rectangles, triangles, and more.

Key Methods

  1. calculateDistance2D(double, double, double, double)
    Calculates the Euclidean distance between two points in 2D space.

    double distance2D = GeometricUtils.calculateDistance2D(1.0, 2.0, 4.0, 6.0);
  2. calculateDistance3D(double, double, double, double, double, double)
    Calculates the Euclidean distance between two points in 3D space.

    double distance3D = GeometricUtils.calculateDistance3D(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
  3. calculateCircleArea(double)
    Calculates the area of a circle given its radius.

    double areaCircle = GeometricUtils.calculateCircleArea(5.0);
  4. calculateCircleCircumference(double)
    Calculates the circumference of a circle given its radius.

    double circumference = GeometricUtils.calculateCircleCircumference(5.0);
  5. calculateRectangleArea(double, double)
    Calculates the area of a rectangle given its width and height.

    double areaRectangle = GeometricUtils.calculateRectangleArea(4.0, 6.0);
  6. calculateRectanglePerimeter(double, double)
    Calculates the perimeter of a rectangle given its width and height.

    double perimeterRectangle = GeometricUtils.calculateRectanglePerimeter(4.0, 6.0);
  7. calculateTriangleArea(double, double)
    Calculates the area of a triangle given its base and height.

    double areaTriangle = GeometricUtils.calculateTriangleArea(4.0, 6.0);
  8. calculateTrianglePerimeter(double, double, double)
    Calculates the perimeter of a triangle given its three sides.

    double perimeterTriangle = GeometricUtils.calculateTrianglePerimeter(3.0, 4.0, 5.0);
  9. calculateSphereVolume(double)
    Calculates the volume of a sphere given its radius.

    double volumeSphere = GeometricUtils.calculateSphereVolume(5.0);
  10. calculateCubeSurfaceArea(double)
    Calculates the surface area of a cube given its side length.

    double surfaceAreaCube = GeometricUtils.calculateCubeSurfaceArea(3.0);
  11. calculateCylinderVolume(double, double)
    Calculates the volume of a cylinder given its radius and height.

    double volumeCylinder = GeometricUtils.calculateCylinderVolume(3.0, 7.0);
  12. calculateConeSurfaceArea(double, double)
    Calculates the surface area of a cone given its radius and slant height.

    double surfaceAreaCone = GeometricUtils.calculateConeSurfaceArea(3.0, 5.0);

Usage Notes

  • Error Handling: If an input is invalid (e.g., a negative radius), the method throws an appropriate exception and logs an error message.
  • Utility Design: This class cannot be instantiated, as it contains a private constructor and only static methods.