blob: a6a759940b092cf942cac80d8fa1332adf1e3d7d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
/*
* CartesianKinematics.cpp
*
* Created on: 6 May 2017
* Author: David
*/
#include "CartesianKinematics.h"
CartesianKinematics::CartesianKinematics() : Kinematics(KinematicsType::cartesian)
{
}
// Return the name of the current kinematics
const char *CartesianKinematics::GetName(bool forStatusReport) const
{
return (forStatusReport) ? "cartesian" : "Cartesian";
}
// Convert Cartesian coordinates to motor coordinates
bool CartesianKinematics::CartesianToMotorSteps(const float machinePos[], const float stepsPerMm[], size_t numAxes, int32_t motorPos[]) const
{
for (size_t axis = 0; axis < numAxes; ++axis)
{
motorPos[axis] = (int32_t)roundf(machinePos[axis] * stepsPerMm[axis]);
}
return true;
}
// Convert motor coordinates to machine coordinates. Used after homing and after individual motor moves.
void CartesianKinematics::MotorStepsToCartesian(const int32_t motorPos[], const float stepsPerMm[], size_t numDrives, float machinePos[]) const
{
// Convert all axes and the extruders
for (size_t drive = 0; drive < numDrives; ++drive)
{
machinePos[drive] = motorPos[drive]/stepsPerMm[drive];
}
}
// End
|