-
Notifications
You must be signed in to change notification settings - Fork 0
/
trvalues.py
31 lines (28 loc) · 951 Bytes
/
trvalues.py
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
# trvalues - track values
#
# SYNTAX
# [y,dydx,d2ydx2,alpha,R]=trvalues(p,x)
#
# INPUT
# p: the n+1 coefficients of a polynomial of degree n, given in descending
# order. (For instance the output from p=iptrack(filename).)
# x: ordinate value at which the polynomial is evaluated.
#
# OUTPUT
# [y,dydx,d2ydx2,alpha,R]=trvalues(p,x) returns the value y of the
# polynomial at x, the derivative dydx and the second derivative d2ydx2 in
# that point, as well as the slope alpha(x) and the radius of the
# osculating circle.
# The slope angle alpha is positive for a curve with a negative derivative.
# The sign of the radius of the osculating circle is the same as that of
# the second derivative.
import numpy as np
def trvalues(p,x):
y=np.polyval(p,x)
dp=np.polyder(p)
dydx=np.polyval(dp,x)
ddp=np.polyder(dp)
d2ydx2=np.polyval(ddp,x)
alpha=np.arctan(-dydx)
R=(1.0+dydx**2)**1.5/d2ydx2
return [y,dydx,d2ydx2,alpha,R]