DEV Community

Cover image for geometry4j - Java Library For Basic Geometry Operations
luthfisauqi17
luthfisauqi17

Posted on • Edited on

geometry4j - Java Library For Basic Geometry Operations

Overview

Have you ever forgotten a geometric formula when building a project. If so, this java library can be your solution. Let me introduce you to geometry4j as one of the tools that can be used to calculate basic geometric operations.
geometry


How to use it

It's fairly easy to use this library, let's take an example. Let's say that we want to calculate the area of a triangle with a base of 3.0 cm and a height of 4.0. You can use the following Java code to find the area of the triangle.

import com.github.luthfisauqi17.geometry4j.Triangle;

public class MyApp {

    public static void main(String[] args) {
        Double base = 3.0;
        Double height = 4.0;
        Double area = Triangle.calculateAreaOfTriangle(base, height);
        System.out.println(area);
    }
}
Enter fullscreen mode Exit fullscreen mode

The above code will produce:

6.0
Enter fullscreen mode Exit fullscreen mode

This is valid because area of triangle = (base * height) / 2. Therefore area of triangle = (3 * 4) / 2 = 12 / 2 = 6.


Future work

This project has not yet been published to the Maven Central Repository, to use it you can publish it to your Local Maven Repository first.

This project is also still experimental and early development as I still learning this technology, so it is recommended not to use this tool in production.

All files in this project are open to anyone who wants to contribute, even the README.md file is open to anyone who wants to add something there. This project is also still relatively small, so it is perfect for beginners who want to learn to contribute to open source applications.

You can access the following for further documentation regarding this project:
https://github.com/luthfisauqi17/geometry4j


Thank you for viewing this post, please give me comments, input, and suggestions that I can use so that me and this project can be better in the future.

Top comments (0)