mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[wpimath] Clean up Java Quaternion class (#4399)
Vector.norm() and Vector.dot() were added to make the implementation simpler and match the C++ version more closely.
This commit is contained in:
30
wpimath/src/test/java/edu/wpi/first/math/VectorTest.java
Normal file
30
wpimath/src/test/java/edu/wpi/first/math/VectorTest.java
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class VectorTest {
|
||||
@Test
|
||||
void testVectorDot() {
|
||||
var vec1 = VecBuilder.fill(1.0, 2.0, 3.0);
|
||||
var vec2 = VecBuilder.fill(4.0, 5.0, 6.0);
|
||||
|
||||
assertEquals(32.0, vec1.dot(vec2));
|
||||
|
||||
var vec3 = VecBuilder.fill(-1.0, 2.0, -3.0);
|
||||
var vec4 = VecBuilder.fill(4.0, -5.0, 6.0);
|
||||
|
||||
assertEquals(-32.0, vec3.dot(vec4));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testVectorNorm() {
|
||||
assertEquals(Math.sqrt(14.0), VecBuilder.fill(1.0, 2.0, 3.0).norm());
|
||||
assertEquals(Math.sqrt(14.0), VecBuilder.fill(1.0, -2.0, 3.0).norm());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user