Generating vertical points from contour

30 Views Asked by At

I have the following contour that is defined: $$ x(t) = R \cdot \sin(t) \\ y(t) = \frac{R \cdot (\cos(t) -1) \cdot \sin(t)}{(1 + \sin(t)) ^2 } \\ t \in [0, 2] $$ Now, I want the collection of points, that each one is in distance $ \alpha $ for example from the contour, and vertical to it (Sadly I don't remember how to solve \ tackle these type of tasks).

A picture to demonstrate what I want to achieve : enter image description here

Python code that generates the infinity shape:

def generate_infinity_shape(num_points, radius=1.0):
    t = np.linspace(0, 2 * np.pi, num_points)
    x = radius * np.sin(t)
    y = radius * (np.cos(t) - 1) * np.sin(t) / (1 + np.sin(t) ** 2)
    coordinates = [(x[i], y[i]) for i in range(num_points)]
    return coordinates


radius = 0.2  # Radius of the infinity shape
coordinates = generate_infinity_shape(num_points, radius)
plt.scatter(*zip(*coordinates))

help would be greatly appreciated !

1

There are 1 best solutions below

0
On BEST ANSWER
  • fix a point $p$ on the curve
  • compute the velocity vector $v_p$ of the curve at $p$
  • divide the velocity vector by its length $u_p = v_p / \| v_p \|$
  • compute the cross product $o_p = u_p \times e_z $ where $e_z$ is the unit vector in the $z$ direction

Then the point $p + \alpha o_p$ has the desired properties