[1]:
from streng.common.math import numerical
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
[8]:
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

area_under_curve

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

intersection

[10]:
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()

[11]:
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

[12]:
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
[ ]: