Initial LinuxCNC WebAssembly workspace snapshot
This commit is contained in:
23
wasm-core/tests/sim_posemath_test.c
Normal file
23
wasm-core/tests/sim_posemath_test.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "sim_posemath.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
int main(void) {
|
||||
sim_posemath_cartesian input = {3.0, 4.0, 0.0};
|
||||
sim_posemath_cartesian output = {0};
|
||||
sim_posemath_cartesian end = {10.0, 10.0, 10.0};
|
||||
double dot = 0;
|
||||
|
||||
assert(sim_posemath_normalize(&input, &output) == SIM_POSEMATH_OK);
|
||||
assert(fabs(output.x - 0.6) < 1e-12 && fabs(output.y - 0.8) < 1e-12);
|
||||
assert(sim_posemath_dot(&input, &end, &dot) == SIM_POSEMATH_OK && dot == 70.0);
|
||||
assert(sim_posemath_line_point(&input, &end, 0.5, &output) == SIM_POSEMATH_OK);
|
||||
assert(output.x == 6.5 && output.y == 7.0 && output.z == 5.0);
|
||||
assert(sim_posemath_line_point(&input, &end, 1.1, &output) == SIM_POSEMATH_ERR_RANGE);
|
||||
input.x = NAN;
|
||||
assert(sim_posemath_normalize(&input, &output) == SIM_POSEMATH_ERR_ARGUMENT);
|
||||
input.x = 0.0; input.y = 0.0; input.z = 0.0;
|
||||
assert(sim_posemath_normalize(&input, &output) == SIM_POSEMATH_ERR_DEGENERATE);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user