Video work (#2318)

* Only use -no-pdf for xelatex rendering

* Instead of tracking du and dv points on surface, track points off the surface in the normal direction

This means that surface shading will not necessarily work well for arbitrary transformations of the surface. But the existing solution was flimsy anyway, and caused annoying issues with singularity points.

* Have density of anchor points on arcs depend on arc length

* Allow for specifying true normals and orientation of Sphere

* Change miter threshold on stroke shader

* Add get_start_and_end to DashedLine

* Add min_total_width option to DecimalNumber

* Have BackgroundRectangle.set_style absorb (and ignore) added configuration

Note, this feels suboptimal

* Add LineBrace

* Update font_size adjustment in Tex
This commit is contained in:
Grant Sanderson
2025-02-26 09:52:59 -06:00
committed by GitHub
parent 7a7bf83f11
commit db421e3981
10 changed files with 65 additions and 41 deletions

View File

@ -97,20 +97,27 @@ class Sphere(Surface):
v_range: Tuple[float, float] = (0, PI),
resolution: Tuple[int, int] = (101, 51),
radius: float = 1.0,
true_normals: bool = True,
clockwise=False,
**kwargs,
):
self.radius = radius
self.clockwise = clockwise
super().__init__(
u_range=u_range,
v_range=v_range,
resolution=resolution,
**kwargs
)
# Add bespoke normal specification to avoid issue at poles
if true_normals:
self.data['d_normal_point'] = self.data['point'] * ((radius + self.normal_nudge) / radius)
def uv_func(self, u: float, v: float) -> np.ndarray:
sign = -1 if self.clockwise else +1
return self.radius * np.array([
math.cos(u) * math.sin(v),
math.sin(u) * math.sin(v),
math.cos(sign * u) * math.sin(v),
math.sin(sign * u) * math.sin(v),
-math.cos(v)
])