Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/main/java/com/thealgorithms/maths/Area.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,21 @@ public static double surfaceAreaCone(final double radius, final double height) {
}
return Math.PI * radius * (radius + Math.pow(height * height + radius * radius, 0.5));
}

/**
* Calculate the area of a rhombus.
*
* @param diagonal1 length of the first diagonal
* @param diagonal2 length of the second diagonal
* @return area of given rhombus
*/
public static double surfaceAreaRhombus(final double diagonal1, final double diagonal2) {
if (diagonal1 <= 0) {
throw new IllegalArgumentException("Diagonal 1 must be greater than 0");
}
if (diagonal2 <= 0) {
throw new IllegalArgumentException("Diagonal 2 must be greater than 0");
}
return diagonal1 * diagonal2 / 2;
}
}
Loading