Closed guiwenfeng closed 4 months ago
I don't quite understand what you are intending to do here:
dot = Dot(axes.get_origin(), color=RED)
class Test(Scene):
def setup(self):
super().setup()
self.axes_config = {
"x_range": [0, 10],
"y_range": [-2.5, 2.5, 0.25],
"x_length": 10,
"y_length": 7.5,
"axis_config": {
"stroke_width": 2,
},
"y_axis_config": {
"include_tip": False,
"numbers_to_include": [-2.0, -1.0, 0.0, 1.0, 2.0],
"numbers_to_exclude": [],
"decimal_number_config": {"num_decimal_places": 1},
},
}
def construct(self):
axes = Axes(**self.axes_config)
y_axis = axes.y_axis
self.add(axes)
dot = Dot(ORIGIN, color=RED)
self.add(dot)
self.wait()
y_axis.shift(dot.get_center()-y_axis.n2p(0))
self.wait()
print(y_axis.get_center())
print(dot.get_center())
https://github.com/user-attachments/assets/4770673e-6753-4a1b-b05c-4720477ba08c
here is another short script highlighting the outlines and handles of an object like your y-axis
class Test2(Scene):
def setup(self):
super().setup()
self.axes_config = {
"x_range": [0, 10],
"y_range": [-2.5, 2.5, 0.25],
"x_length": 10,
"y_length": 7.5,
"axis_config": {
"stroke_width": 2,
},
"y_axis_config": {
"include_tip": False,
"numbers_to_include": [-2.0, -1.0, 0.0, 1.0, 2.0],
"numbers_to_exclude": [],
"decimal_number_config": {"num_decimal_places": 1},
},
}
def construct(self):
axes = Axes(**self.axes_config)
y_axis = axes.y_axis
self.add(axes.set_opacity(0.7))
for cp in [RIGHT,UR,UP,UL,LEFT,DL,DOWN,DR]:
self.add(Dot(point=y_axis.get_critical_point(cp),radius=0.05,color=YELLOW))
self.add(Dot(point=y_axis.get_center(),radius=0.05,color=TEAL))
self.add(Dot(point=y_axis.n2p(0),radius=0.05,color=RED))
self.add(SurroundingRectangle(y_axis, buff=0).set_fill(opacity=0).set_stroke(opacity=1,color=BLUE,width=1))
This is a demo, and when I was learning someone else's code, I found that the generated video was a little different from what I wanted, and I thought something might be wrong. Thank you very much for your reply, your reply perfectly solved my issue.
I thought the y_axis center points should coincide with the dot, but now they don't
https://github.com/user-attachments/assets/106aab2d-704f-4363-b9d9-84594bb5cd04