Skip to content

Commit 450709d

Browse files
MajewskiKrzysztofjzheaux
authored andcommitted
Using Math.sin with Degrees
Issue: BAEL-2157
1 parent d7dac62 commit 450709d

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.baeldung.maths;
2+
3+
import static org.junit.Assert.assertTrue;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
public class MathSinUnitTest {
8+
9+
@Test
10+
public void givenAnAngleInDegrees_whenUsingToRadians_thenResultIsInRadians() {
11+
double angleInDegrees = 30;
12+
double sinForDegrees = Math.sin(Math.toRadians(angleInDegrees)); // 0.5
13+
14+
double thirtyDegreesInRadians = 1/6 * Math.PI;
15+
double sinForRadians = Math.sin(thirtyDegreesInRadians); // 0.5
16+
17+
assertTrue(sinForDegrees == sinForRadians);
18+
}
19+
20+
}

0 commit comments

Comments
 (0)