summaryrefslogtreecommitdiff
path: root/src/emc/kinematics/cubic.h
blob: 6614ec705b42d664d35a0cb89a2094256ba832aa (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/********************************************************************
* Description: cubic.h
*   Cubic polynomial interpolation code
*
*   Derived from a work by Fred Proctor & Will Shackleford
*
* Author:
* License: GPL Version 2
* System: Linux
*    
* Copyright (c) 2004 All rights reserved.
*
* Last change:
********************************************************************/
#ifndef CUBIC_H
#define CUBIC_H

/*
   Coefficients of a cubic polynomial,

   a * x^3 + b * x^2 + c * x + d
*/

typedef struct {
    double a;
    double b;
    double c;
    double d;
} CUBIC_COEFF;

typedef struct {
    int configured;
    double segmentTime;
    int interpolationRate;
    double interpolationTime;
    double interpolationIncrement;
    double x0, x1, x2, x3;
    double wp0, wp1;
    double velp0, velp1;
    int filled;
    int needNextPoint;
    CUBIC_COEFF coeff;
} CUBIC_STRUCT;

extern int cubicInit(CUBIC_STRUCT * ci);
extern int cubicSetSegmentTime(CUBIC_STRUCT * ci, double time);
extern double cubicGetSegmentTime(CUBIC_STRUCT * ci);
extern int cubicSetInterpolationRate(CUBIC_STRUCT * ci, int rate);
extern int cubicGetInterpolationRate(CUBIC_STRUCT * ci);
extern int cubicAddPoint(CUBIC_STRUCT * ci, double point);
extern int cubicOffset(CUBIC_STRUCT * ci, double offset);
extern double cubicGetInterpolationIncrement(CUBIC_STRUCT * ci);
extern CUBIC_COEFF cubicGetCubicCoeff(CUBIC_STRUCT * ci);
extern int cubicFilled(CUBIC_STRUCT * ci);
extern double cubicInterpolate(CUBIC_STRUCT * ci, double *x,	/* same as
								   return val 
								 */
			       double *v,	/* velocity */
			       double *a,	/* accel */
			       double *j);	/* jerk */
extern int cubicNeedNextPoint(CUBIC_STRUCT * ci);
extern int cubicDrain(CUBIC_STRUCT * ci);

#endif				/* CUBIC_H */