Bug fixes to ThreeDAxes

This commit is contained in:
Grant Sanderson 2018-08-27 16:31:05 -07:00
parent 35a59474fe
commit 8ea4f8fda8

View file

@ -48,11 +48,12 @@ class Axes(VGroup):
config.update(extra_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)
x_axis_projection = self.x_axis.number_to_point(x)
y_axis_projection = self.y_axis.number_to_point(y)
return x_axis_projection + y_axis_projection - origin
result = np.array(origin)
for axis, coord in zip(self, coords):
result += (axis.number_to_point(coord) - origin)
return result
def point_to_coords(self, point):
return tuple([
@ -138,9 +139,10 @@ class ThreeDAxes(Axes):
def add_3d_pieces(self):
for axis in self:
axis.add(VGroup(
axis.pieces = VGroup(
*axis.main_line.get_pieces(self.num_axis_pieces)
))
)
axis.add(axis.pieces)
axis.main_line.set_stroke(width=0, family=False)
for submob in axis.family_members_with_points():
submob.shade_in_3d = True
@ -365,10 +367,11 @@ class ComplexPlane(NumberPlane):
numbers += [
complex(0, y)
for y in range(-int(self.y_radius), int(self.y_radius) + 1)
if y != 0
]
for number in numbers:
if number == complex(0, 0):
continue
# if number == complex(0, 0):
# continue
point = self.number_to_point(number)
num_str = str(number).replace("j", "i")
if num_str.startswith("0"):