Atan2: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
|||
Zeile 18: | Zeile 18: | ||
<span class="mw-customtoggle-myDivision">[Anzeigen]</span> | <span class="mw-customtoggle-myDivision">[Anzeigen]</span> | ||
<syntaxhighlight lang="java" class="mw-collapsible mw-collapsed" id="mw-customcollapsible-myDivision"> | <syntaxhighlight lang="java" class="mw-collapsible mw-collapsed" id="mw-customcollapsible-myDivision"> | ||
@ | private double PI = Math.PI; | ||
public void | |||
@Test(expected = FunctionInvalidArgumentException.class) | |||
public void testAtan2_1() { | |||
assertEquals(0, Evaluator.getNumberResult("atan2('0','0')", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testAtan2_2() { | ||
assertEquals(0, Evaluator.getNumberResult("atan2('0','0.5')", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testAtan2_3() { | ||
assertEquals(0.7853981633974483, | |||
Evaluator.getNumberResult("atan2('0.5','0.5')", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testAtan2AtDefinition1() { | ||
assertEquals(PI, Evaluator.getNumberResult("atan2(0, -1)", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testAtan2AtDefinition2() { | ||
assertEquals(0, Evaluator.getNumberResult("atan2(0, 1)", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testAtan2AtDefinition3() { | ||
assertEquals(PI / 2, Evaluator.getNumberResult("atan2(1, 0)", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test(expected= | @Test | ||
public void testAtan2AtDefinition4() { | |||
assertEquals(-PI / 2, Evaluator.getNumberResult("atan2(-1, 0)", exerciseVariableMap, fillInVariableMap), | |||
0.0001); | |||
} | |||
@Test(expected = FunctionInvalidArgumentException.class) | |||
public void testAtan2WithInput1() { | |||
assertEquals(0, Evaluator.getNumberResult("atan2('0','[pos=1]')", exerciseVariableMap, fillInVariableMap), | |||
0.0001); | |||
} | |||
@Test | |||
public void testAtan2WithInput2() { | |||
assertEquals(PI / 2, | |||
Evaluator.getNumberResult("atan2('[pos=2]','[pos=1]')", exerciseVariableMap, fillInVariableMap), | |||
0.0001); | |||
} | |||
@Test(expected = FunctionInvalidArgumentException.class) | |||
public void testAtan2WithVariables1() { | |||
assertEquals(0, Evaluator.getNumberResult("atan2('[var=a]','0')", exerciseVariableMap, fillInVariableMap), | |||
0.0001); | |||
} | |||
@Test | |||
public void testAtan2WithVariables2() { | |||
assertEquals(PI / 2, | |||
Evaluator.getNumberResult("atan2('[var=b]','[var=a]')", exerciseVariableMap, fillInVariableMap), | |||
0.0001); | |||
} | |||
@Test(expected = FunctionInvalidArgumentException.class) | |||
public void testAtan2WithExpression1() { | |||
assertEquals(0, | |||
Evaluator.getNumberResult("atan2(atan2(0, 0), atan2(0, 0))", exerciseVariableMap, fillInVariableMap), | |||
0.0001); | |||
fail(); | |||
} | |||
@Test(expected = FunctionInvalidArgumentException.class) | |||
public void testAtan2WithExpression2() { | |||
assertEquals(0, Evaluator.getNumberResult("atan2(atan2(0, 0), atan2(0, atan2(0, 0)))", exerciseVariableMap, | |||
fillInVariableMap), 0.0001); | |||
fail(); | |||
} | |||
@Test(expected = FunctionInvalidArgumentTypeException.class) | |||
public void testAtan2WithONECharacter() { | public void testAtan2WithONECharacter() { | ||
Evaluator.getNumberResult("atan2(a, a)", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidArgumentTypeException.class) | ||
public void testAtan2WithEmptyStringArguments() { | public void testAtan2WithEmptyStringArguments() { | ||
Evaluator.getNumberResult("atan2('', '')", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidNumberOfArgumentsException.class) | ||
public void testAtan2WithEmptyArgument() { | public void testAtan2WithEmptyArgument() { | ||
Evaluator.getNumberResult("atan2()", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected=UndefinedExerciseVariableException.class) | @Test(expected = UndefinedExerciseVariableException.class) | ||
public void testAtan2WithoutExerciseVariable() { | public void testAtan2WithoutExerciseVariable() { | ||
Evaluator.getNumberResult("atan2([var=j], [var=j])", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected=UndefinedFillInVariableException.class) | @Test(expected = UndefinedFillInVariableException.class) | ||
public void testAtan2WithoutInput() { | public void testAtan2WithoutInput() { | ||
Evaluator.getNumberResult("atan2([pos=42], [pos=42])", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |
Version vom 18. September 2017, 10:24 Uhr
Beschreibung
Der Arkustangens 2 wird durch die Funktion atan2 beschrieben. Sie erwartet zwei Parameter und gibt einen Wert zurück.
Syntax
atan2(String zahl1,String zahl2)
Parameter
- zahl1 - der x-Wert der kartesischen Koordinaten
- zahl2 - der y-Wert der kartesischen Koordinaten
Return Value
- Gibt den Wert des Arkustangens 2 an der Stelle zurück.
Beispiele
atan2('0','0') --> returns 0
JUnit Tests
[Anzeigen]
private double PI = Math.PI;
@Test(expected = FunctionInvalidArgumentException.class)
public void testAtan2_1() {
assertEquals(0, Evaluator.getNumberResult("atan2('0','0')", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testAtan2_2() {
assertEquals(0, Evaluator.getNumberResult("atan2('0','0.5')", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testAtan2_3() {
assertEquals(0.7853981633974483,
Evaluator.getNumberResult("atan2('0.5','0.5')", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testAtan2AtDefinition1() {
assertEquals(PI, Evaluator.getNumberResult("atan2(0, -1)", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testAtan2AtDefinition2() {
assertEquals(0, Evaluator.getNumberResult("atan2(0, 1)", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testAtan2AtDefinition3() {
assertEquals(PI / 2, Evaluator.getNumberResult("atan2(1, 0)", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testAtan2AtDefinition4() {
assertEquals(-PI / 2, Evaluator.getNumberResult("atan2(-1, 0)", exerciseVariableMap, fillInVariableMap),
0.0001);
}
@Test(expected = FunctionInvalidArgumentException.class)
public void testAtan2WithInput1() {
assertEquals(0, Evaluator.getNumberResult("atan2('0','[pos=1]')", exerciseVariableMap, fillInVariableMap),
0.0001);
}
@Test
public void testAtan2WithInput2() {
assertEquals(PI / 2,
Evaluator.getNumberResult("atan2('[pos=2]','[pos=1]')", exerciseVariableMap, fillInVariableMap),
0.0001);
}
@Test(expected = FunctionInvalidArgumentException.class)
public void testAtan2WithVariables1() {
assertEquals(0, Evaluator.getNumberResult("atan2('[var=a]','0')", exerciseVariableMap, fillInVariableMap),
0.0001);
}
@Test
public void testAtan2WithVariables2() {
assertEquals(PI / 2,
Evaluator.getNumberResult("atan2('[var=b]','[var=a]')", exerciseVariableMap, fillInVariableMap),
0.0001);
}
@Test(expected = FunctionInvalidArgumentException.class)
public void testAtan2WithExpression1() {
assertEquals(0,
Evaluator.getNumberResult("atan2(atan2(0, 0), atan2(0, 0))", exerciseVariableMap, fillInVariableMap),
0.0001);
fail();
}
@Test(expected = FunctionInvalidArgumentException.class)
public void testAtan2WithExpression2() {
assertEquals(0, Evaluator.getNumberResult("atan2(atan2(0, 0), atan2(0, atan2(0, 0)))", exerciseVariableMap,
fillInVariableMap), 0.0001);
fail();
}
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testAtan2WithONECharacter() {
Evaluator.getNumberResult("atan2(a, a)", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testAtan2WithEmptyStringArguments() {
Evaluator.getNumberResult("atan2('', '')", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testAtan2WithEmptyArgument() {
Evaluator.getNumberResult("atan2()", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = UndefinedExerciseVariableException.class)
public void testAtan2WithoutExerciseVariable() {
Evaluator.getNumberResult("atan2([var=j], [var=j])", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = UndefinedFillInVariableException.class)
public void testAtan2WithoutInput() {
Evaluator.getNumberResult("atan2([pos=42], [pos=42])", exerciseVariableMap, fillInVariableMap);
fail();
}