mirror of
https://github.com/3b1b/manim.git
synced 2025-09-19 04:41:56 +00:00
Bug fixes to ThreeDAxes
This commit is contained in:
parent
35a59474fe
commit
8ea4f8fda8
1 changed files with 11 additions and 8 deletions
|
@ -48,11 +48,12 @@ class Axes(VGroup):
|
||||||
config.update(extra_config)
|
config.update(extra_config)
|
||||||
return NumberLine(x_min=min_val, x_max=max_val, **config)
|
return NumberLine(x_min=min_val, x_max=max_val, **config)
|
||||||
|
|
||||||
def coords_to_point(self, x, y):
|
def coords_to_point(self, *coords):
|
||||||
origin = self.x_axis.number_to_point(0)
|
origin = self.x_axis.number_to_point(0)
|
||||||
x_axis_projection = self.x_axis.number_to_point(x)
|
result = np.array(origin)
|
||||||
y_axis_projection = self.y_axis.number_to_point(y)
|
for axis, coord in zip(self, coords):
|
||||||
return x_axis_projection + y_axis_projection - origin
|
result += (axis.number_to_point(coord) - origin)
|
||||||
|
return result
|
||||||
|
|
||||||
def point_to_coords(self, point):
|
def point_to_coords(self, point):
|
||||||
return tuple([
|
return tuple([
|
||||||
|
@ -138,9 +139,10 @@ class ThreeDAxes(Axes):
|
||||||
|
|
||||||
def add_3d_pieces(self):
|
def add_3d_pieces(self):
|
||||||
for axis in self:
|
for axis in self:
|
||||||
axis.add(VGroup(
|
axis.pieces = VGroup(
|
||||||
*axis.main_line.get_pieces(self.num_axis_pieces)
|
*axis.main_line.get_pieces(self.num_axis_pieces)
|
||||||
))
|
)
|
||||||
|
axis.add(axis.pieces)
|
||||||
axis.main_line.set_stroke(width=0, family=False)
|
axis.main_line.set_stroke(width=0, family=False)
|
||||||
for submob in axis.family_members_with_points():
|
for submob in axis.family_members_with_points():
|
||||||
submob.shade_in_3d = True
|
submob.shade_in_3d = True
|
||||||
|
@ -365,10 +367,11 @@ class ComplexPlane(NumberPlane):
|
||||||
numbers += [
|
numbers += [
|
||||||
complex(0, y)
|
complex(0, y)
|
||||||
for y in range(-int(self.y_radius), int(self.y_radius) + 1)
|
for y in range(-int(self.y_radius), int(self.y_radius) + 1)
|
||||||
|
if y != 0
|
||||||
]
|
]
|
||||||
for number in numbers:
|
for number in numbers:
|
||||||
if number == complex(0, 0):
|
# if number == complex(0, 0):
|
||||||
continue
|
# continue
|
||||||
point = self.number_to_point(number)
|
point = self.number_to_point(number)
|
||||||
num_str = str(number).replace("j", "i")
|
num_str = str(number).replace("j", "i")
|
||||||
if num_str.startswith("0"):
|
if num_str.startswith("0"):
|
||||||
|
|
Loading…
Add table
Reference in a new issue