File:Affine focal set elliptic curve.svg
From testwiki
Jump to navigation
Jump to search
Original file (SVG file, nominally 654 × 739 pixels, file size: 30 KB)
Contents
This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.
Summary
| DescriptionAffine focal set elliptic curve.svg |
English: Affine focal set elliptic curve
Matplotlib codeimport numpy as np
import matplotlib.pyplot as plt
def plot_affine_normals(curve_func, t0, t1, t_samples, d,
n_curve=400,
eps=1e-8):
t_samples = np.asarray(t_samples, dtype=float)
# --- dense curve for backbone and scaling ---
t_dense = np.linspace(t0, t1, n_curve)
curve_dense = np.asarray(curve_func(t_dense))
if curve_dense.ndim == 1:
curve_dense = curve_dense.reshape(-1, 2)
# --- sample points for lines and normals ---
pts = np.asarray(curve_func(t_samples))
if pts.ndim == 1:
pts = pts.reshape(-1, 2)
# numerical derivatives wrt t for affine normal
x = pts[:, 0]
y = pts[:, 1]
dx = np.gradient(x, t_samples, edge_order=2)
dy = np.gradient(y, t_samples, edge_order=2)
ddx = np.gradient(dx, t_samples, edge_order=2)
ddy = np.gradient(dy, t_samples, edge_order=2)
dddx = np.gradient(ddx, t_samples, edge_order=2)
dddy = np.gradient(ddy, t_samples, edge_order=2)
# tangent (Euclidean)
T = np.vstack((dx, dy)).T
T_norm = np.linalg.norm(T, axis=1, keepdims=True)
T_norm[T_norm < eps] = 1.0
T_unit = T / T_norm
# affine normal direction (unnormalized)
# Δ = [γ', γ''], Δ' = d/dt Δ
Delta = dx * ddy - dy * ddx
Delta_p = np.gradient(Delta, t_samples, edge_order=2)
N_aff = np.vstack(
(Delta * ddx - (1.0 / 3.0) * Delta_p * dx,
Delta * ddy - (1.0 / 3.0) * Delta_p * dy)
).T
N_aff_norm = np.linalg.norm(N_aff, axis=1, keepdims=True)
mask_aff = N_aff_norm[:, 0] > eps
N_aff_unit = np.zeros_like(N_aff)
N_aff_unit[mask_aff] = N_aff[mask_aff] / N_aff_norm[mask_aff]
# Euclidean normal for "inward" offset
N_e = np.vstack((-T_unit[:, 1], T_unit[:, 0])).T
# geometric scale for line lengths
all_xy = curve_dense
xmin, ymin = np.min(all_xy, axis=0)
xmax, ymax = np.max(all_xy, axis=0)
dx_box, dy_box = xmax - xmin, ymax - ymin
scale = max(dx_box, dy_box)
if scale < eps:
scale = 1.0
line_half_len = 0.18 * scale
normal_half_len = 0.22 * scale
# center for "inward" direction
center = np.mean(all_xy, axis=0)
# sign for inward offset
to_center = center[None, :] - pts
dot_nc = np.sum(N_e * to_center, axis=1)
sign = np.sign(dot_nc)
sign[sign == 0] = 1.0
sign = sign[:, None]
offset1 = sign * d * N_e
offset2 = sign * (2 * d) * N_e
fig, ax = plt.subplots(figsize=(10, 10))
# main curve
ax.plot(curve_dense[:, 0], curve_dense[:, 1], linewidth=2, color="#4a5a90")
# tangents and parallels
for P, Tu, off1, off2 in zip(pts, T_unit, offset1, offset2):
# base tangent
P0 = P - line_half_len * Tu
P1 = P + line_half_len * Tu
ax.plot([P0[0], P1[0]], [P0[1], P1[1]], linewidth=1.0, alpha=0.9, color="#938fba")
# offset by d
Q = P + off1
Q0 = Q - line_half_len * Tu
Q1 = Q + line_half_len * Tu
ax.plot([Q0[0], Q1[0]], [Q0[1], Q1[1]], linewidth=1.0, alpha=0.5, color="#938fba")
# offset by 2d
R = P + off2
R0 = R - line_half_len * Tu
R1 = R + line_half_len * Tu
ax.plot([R0[0], R1[0]], [R0[1], R1[1]], linewidth=1.0, alpha=0.3, color="#938fba")
# affine normal lines
for P, Na, ok in zip(pts, N_aff_unit, mask_aff):
if not ok:
continue
A0 = P - 0 * normal_half_len * Na
A1 = P + 6 * normal_half_len * Na
ax.plot([A0[0], A1[0]], [A0[1], A1[1]], linewidth=1.0, alpha=0.8, color="#4f0808")
# sample points
ax.scatter(pts[:, 0], pts[:, 1], s=15)
# auto range with margin
all_xy = np.vstack((all_xy, pts))
xmin, ymin = np.min(all_xy, axis=0)
xmax, ymax = np.max(all_xy, axis=0)
dx_box, dy_box = xmax - xmin, ymax - ymin
margin_x = 0.15 * dx_box if dx_box > 0 else 1.0
margin_y = 0.15 * dy_box if dy_box > 0 else 1.0
ax.set_xlim(xmin - margin_x, xmax + margin_x)
ax.set_ylim(ymin - margin_y, ymax + margin_y)
ax.set_aspect("equal", adjustable="box")
ax.axis("off")
return fig, ax
fig, ax = plot_affine_normals(cusp_curve, -1.3, 1.3, np.linspace(-1, 1, 30), 0.02)
fig.savefig("affine_focal_set_elliptic_curve.svg")
fig.show()
|
| Date | |
| Source | Own work |
| Author | Cosmia Nebula |
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
This media file is uncategorized.
Please help improve this media file by adding it to one or more categories, so it may be associated with related media files (how?), and so that it can be more easily found.
Please notify the uploader with {{subst:Please link images|File:Affine focal set elliptic curve.svg}} ~~~~ |
Captions
Add a one-line explanation of what this file represents
Items portrayed in this file
depicts
some value
30,249 byte
image/svg+xml
dba525700144566347940acc97c87a9225d10929
23 November 2025
File history
Click on a date/time to view the file as it appeared at that time.
| Date/Time | Thumbnail | Dimensions | User | Comment | |
|---|---|---|---|---|---|
| current | 10:59, 24 November 2025 | 654 × 739 (30 KB) | wikimediacommons>Cosmia Nebula | u |
File usage
There are no pages that use this file.