Example #1
0
 def test_plot(self):
     b = get_single_bspline(self.b)
     plotting.plot(b)
Example #2
0
 def test_plot(self):
     plotting.plot(self.b, with_knots=False)
     plotting.plot(self.b, with_knots=True)
Example #3
0
# control points for first cubic spline:
x01 = np.array([0.2,-0.5,1])
x01=x01/np.linalg.norm(x01)
x02 = np.array([0, -0.3, 1])
x02 = x02/np.linalg.norm(x02)
initial_control_points= np.array([x01,x02])
b = c2spline(interpolation_points, initial_control_points, geometry=geometry.Sphere_geometry())

t=2.
h = np.power(10.0, range(-2,-6,-1))
print((b(t+1.5*h)-3*b(t+0.5*h)+3*b(t-0.5*h)-b(t-1.5*h))/(h*h).reshape(h.shape +(1,))) 
print("If C_2, these should approach zero.")


fig1=plt.figure(1)
splt.plot(b)
fig1.suptitle('Spline on S^2, stereographically projected onto R^2')



hh=1e-5
ts = np.linspace(0.,3., 3*2000)
ts= ts[1:-1]
ddb=np.array([]).reshape(0,3)
for tt in ts:
    temp=np.array((b(tt+hh)-2*b(tt)+b(tt-hh))/(hh*hh))
    temp=temp[np.newaxis, :]
    ddb = np.append(ddb, temp, axis=0) # There should be a better way of doing this.
fig2=plt.figure(2)
plt.plot(ddb[:,0],ddb[:, 1],linestyle='None', marker=',')
fig2.suptitle('Second derivative of spline')
#initial and end velocities:
init_vel = np.array([-1.0,0.0,-1.0])
end_vel = np.array([-1.0,0.0,1.0])
#boundary_velocities=np.array([init_vel, end_vel])


b= implicitc2spline(interpolation_points, geometry=geometry.Sphere_geometry())
h = np.power(10.0, range(-2,-6,-1))
t=1.0
print((b(t+1.5*h)-3*b(t+0.5*h)+3*b(t-0.5*h)-b(t-1.5*h))/(h*h).reshape(h.shape +(1,))) 
print("If C_2, these should approach zero.")

# Plot using bspline.plotting (currently projected 2D plot)
if True:
	fig1=plt.figure(1)
	splt.plot(b, with_control_points=True)
	fig1.suptitle('Spline on S^2, stereographically projected onto R^2')
	t=np.floor(N/2)

# Plot geodesic acceleration second derivative
if True:
    hh=1e-5
    ts = np.linspace(0.,N-1,(N-1)*100)[1:-1]
    ddb = (b(ts+hh)-2*b(ts)+b(ts-hh))/hh**2
    ddb = ddb-np.einsum('ij,ij-> i', b(ts), ddb)[..., np.newaxis]*b(ts)
    fig2 = plt.figure(2)
    plt.plot(ddb[:,0], ddb[:,1], linestyle='None', marker=',')
    fig2.suptitle('Second derivative of spline')

# Plot on the embedded sphere
if True:
#interpolation_points=np.array([[1,0], [np.sqrt(0.5),np.sqrt(0.5)*1j], [1,0]])
#initial and end velocities:
init_vel = np.zeros(d, dtype='complex128')
end_vel = np.zeros(d, dtype='complex128')
boundary_velocities=np.array([init_vel, end_vel])


b= implicitc2spline(interpolation_points, geometry=geometry.CP_geometry(), Maxiter=10000)
#h = np.power(10.0, range(-2,-6,-1))
#print((b(t+1.5*h)-3*b(t+0.5*h)+3*b(t-0.5*h)-b(t-1.5*h))/(h*h).reshape(h.shape +(1,))) 
#print("If C_2, these should approach zero.")

# Plot using bspline.plotting (currently projected 2D plot)
if True:
    fig1=plt.figure(1)
    splt.plot(b, with_control_points=False)
    fig1.suptitle('Spline on S^2, stereographically projected onto R^2')
    t=np.floor(N/2)    
    


# Plot second derivative
if True:
    hh=1e-5
    ts = np.linspace(0.,N-1,(N-1)*100)[1:-1]
    ddb = np.zeros((ts.shape[0],d), dtype=interpolation_points.dtype)
    pm1=b(ts-hh)
    p0=b(ts)
    p1=b(ts+hh)
    am = np.einsum('ij,ij->i',pm1.conj(), p0)
    ap = np.einsum('ij,ij->i', p1.conj(), p0)
Example #6
0
init_vel = np.array([-1.0, 0.0, -1.0])
end_vel = np.array([-1.0, 0.0, 1.0])
#boundary_velocities=np.array([init_vel, end_vel])

b = implicitc2spline(interpolation_points, geometry=geometry.Sphere_geometry())
h = np.power(10.0, range(-2, -6, -1))
t = 1.0
print(
    (b(t + 1.5 * h) - 3 * b(t + 0.5 * h) + 3 * b(t - 0.5 * h) - b(t - 1.5 * h))
    / (h * h).reshape(h.shape + (1, )))
print("If C_2, these should approach zero.")

# Plot using bspline.plotting (currently projected 2D plot)
if True:
    fig1 = plt.figure(1)
    splt.plot(b, with_control_points=True)
    fig1.suptitle('Spline on S^2, stereographically projected onto R^2')
    t = np.floor(N / 2)

# Plot geodesic acceleration second derivative
if True:
    hh = 1e-5
    ts = np.linspace(0., N - 1, (N - 1) * 100)[1:-1]
    ddb = (b(ts + hh) - 2 * b(ts) + b(ts - hh)) / hh**2
    ddb = ddb - np.einsum('ij,ij-> i', b(ts), ddb)[..., np.newaxis] * b(ts)
    fig2 = plt.figure(2)
    plt.plot(ddb[:, 0], ddb[:, 1], linestyle='None', marker=',')
    fig2.suptitle('Second derivative of spline')

# Plot on the embedded sphere
if True: