In [15]:
from streng.common.math import numerical
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
In [10]:
x1 = a * phi - b * np.sin(phi)
y1 = a - b*np.cos(phi)
x2=phi
y2=np.sin(phi)+2

area_under_curve

In [11]:
area_under_curve = numerical.area_under_curve(x2, y2, 3.5, 7.4)
print(area_under_curve)
6.425571959881287

intersection

In [12]:
print(numerical.intersection.__doc__)
Copied from https://github.com/sukhbinder/intersection
    INTERSECTIONS Intersections of curves.
    Computes the (x,y) locations where two curves intersect.  The curves
    can be broken with NaNs or have vertical segments.
        usage:
        x,y=intersection(x1,y1,x2,y2)
        Example:
            a, b = 1, 2
            phi = np.linspace(3, 10, 100)
            x1 = a*phi - b*np.sin(phi)
            y1 = a - b*np.cos(phi)
            x2=phi
            y2=np.sin(phi)+2
            x,y=intersection(x1,y1,x2,y2)
            plt.plot(x1,y1,c='r')
            plt.plot(x2,y2,c='g')
            plt.plot(x,y,'*k')
            plt.show()

In [13]:
a, b = 1, 2
phi = np.linspace(3, 10, 100)
x,y=numerical.intersection(x1,y1,x2,y2)
plt.plot(x1,y1,c='r')
plt.plot(x2,y2,c='g')
plt.plot(x,y,'*k')
plt.show()
../../../_images/jupyters_common_math_numerical_6_0.png

xy_with_endpoints

In [14]:
xx1, yy1 = numerical.xy_with_endpoints(x1, y1, 4.5, 9.0)
xx2, yy2 = numerical.xy_with_endpoints(x2, y2, 3.5, 7.4)
plt.plot(xx1,yy1,c='r')
plt.plot(xx2,yy2,c='g')
plt.show()
../../../_images/jupyters_common_math_numerical_8_0.png
In [ ]: