def __init__(self,d1,d2,r,n1,n2): """ two lines and a distance. n1 and n2 are 0 or 1 and indicating which sector has to be marked. 'n1' if for the intersection with d1. If 'n1=0' then we choose the intersection nearest to d1.I Similarly for n2 """ ObjectGraph.__init__(self,self) self.d1=d1 self.d2=d2 # If the intersection point is one of the initial or final point of d1 or d2, then the sorting # in 'action_on_pspict' does not work. # This happens in RightAngle( Segment(D,E),Segment(D,F),l=0.2, n1=1,n2=1 ) because the same point 'D' is given # for both d1 and d2. # We need d1.I, d1.F, d2.I and d2.F to be four distinct points. if self.d1.I.is_almost_equal(self.d2.I) or self.d1.I.is_almost_equal(self.d2.F) or self.d1.F.is_almost_equal(self.d2.I) or self.d1.F.is_almost_equal(self.d2.F): self.d1=d1.dilatation(1.5) self.d2=d2.dilatation(1.5) self.r=r self.n1=n1 self.n2=n2 self.intersection=Intersection(d1,d2)[0] # If the intersection point is one of the given points, # there will be troubles. # For then angle between AB and CD at point I, we need A,B,C,D # and I to be five different points. if self.intersection.is_almost_equal(self.d1.I) or self.intersection.is_almost_equal(self.d1.F): self.d1=d1.dilatation(1.5) if self.intersection.is_almost_equal(self.d2.I) or self.intersection.is_almost_equal(self.d2.F): self.d2=d2.dilatation(1.5)
def __init__(self, implicit_curve, xrange, yrange, plot_points=300): ObjectGraph.__init__(self, implicit_curve) GeometricImplicitCurve.__init__(self, implicit_curve.f) self.implicit_curve = implicit_curve self.implicit_plot = implicit_plot(self.f, xrange, yrange) self.xrange = xrange self.yrange = yrange self.plot_points = plot_points self.paths = get_paths_from_implicit_plot(self.implicit_plot) self.parameters.color = "blue"
def __init__(self, P, text, hide=True): ObjectGraph.__init__(self, self) self.P = P self.text = text self.mark = Mark(self, 0, 0, self.text) self.hide = hide self.rectangle = Rectangle(Point(0, 0), Point( 1, 1)) # This is fake; just to have an object to act on. self.rectangle.parameters.filled() self.rectangle.parameters.fill.color = "white" self.rectangle.parameters.style = "none"
def __init__(self,center,radius,a,b): """ The pie diagram for the fraction 'a/b' inside the circle of given center and radius. 2/4 and 1/2 are not treated in the same way because 2/4 divides the pie into 4 parts (and fills 2) while 1/2 divides into 2 parts (and fills 1). """ ObjectGraph.__init__(self,self) self.center=center self.radius=radius self.numerator=a self.denominator=b if a>b: raise ValueError,"Numerator is larger than denominator" self.circle=Circle(self.center,self.radius) self._circular_sector=None
def __init__(self,center,radius,angleI=0,angleF=360,visual=False,pspict=None): GenericCurve.__init__(self,pI=angleI,pF=angleF) self.linear_plotpoints=Defaults.CIRCLE_LINEAR_PLOTPOINTS self.center = center self.radius = radius ObjectGraph.__init__(self,self) self.diameter = 2*self.radius self._parametric_curve=None self.angleI = AngleMeasure(value_degree=angleI,keep_negative=True) self.angleF = AngleMeasure(value_degree=angleF,keep_negative=True) a=numerical_approx(self.angleI.degree) b=numerical_approx(self.angleF.degree) self.visual=visual self.pspict=pspict self._equation=None self._numerical_equation=None
def __init__(self, n, l, h): """ Une pyramide contenant 'n' rectangles à la base. Ils ont une longueur 'l' et une hauteur 'h'. """ ObjectGraph.__init__(self, self) self.rectangles = [] self.centres = {} for i in range(0, n): y = i * h for j in range(0, n - i): x = j * l + i * (l / 2) rect = Polygon(Point(x, y), Point(x + l, y), Point(x + l, y - h), Point(x, y - h)) self.rectangles.append(rect) self.centres[(j, i)] = Point(x + l / 2, y - h / 2)
def __init__(self, C, bb, pspict=None): # if a pspicture is passed, these axes will be considered as the # default axes system of `pspict`. This has an influence in the # computation of the bounding box. ObjectGraph.__init__(self, self) self.take_math_BB = False self.C = C self.BB = bb.copy() self.pspict = pspict self.options = Options() self.Dx = 1 self.Dy = 1 self.arrows = "->" self.separator_name = "AXES" self.graduation = True self.numbering = True # Since the size of the axe is given in multiple of self.base, # one cannot give mx=-1000 as "minimal value". self.single_axeX = SingleAxe(self.C, Vector(1, 0), 0, 0, pspict=self.pspict) self.single_axeX.mark_origin = False self.single_axeX.axes_unit = AxesUnit(1, "") self.draw_single_axeX = True self.single_axeY = SingleAxe(self.C, Vector(0, 1), 0, 0, pspict=self.pspict) self.single_axeY.mark_origin = False self.single_axeY.axes_unit = AxesUnit(1, "") self.single_axeY.mark_angle = 180 self.draw_single_axeY = True self.single_axeX.Dx = self.Dx self.single_axeY.Dx = self.Dy self.already_enlarged = False self.enlarge_size = 0.5 self.do_enlarge = True self.do_mx_enlarge = True self.do_my_enlarge = True self.do_Mx_enlarge = True self.do_My_enlarge = True
def __init__(self,A,O,B,r=None): self.A=A self.O=O self.B=B if r==None: r=0.5 # Does not depend on the radius because we are giving a 'visual' length. self.r=r self.angleA=AffineVector(O,A).angle() self.angleB=AffineVector(O,B).angle() # I think that one does not have to check and fix what angle is first here # because the angles are re-computed in self.circle. self.angleI=self.angleA self.angleF=self.angleB ObjectGraph.__init__(self,self) self._mark_angle=None
def __init__(self, graph, dist, angle, text, mark_point=None, central_point=None, position=None, pspict=None): ObjectGraph.__init__(self, self) self.take_math_BB = False self._central_point = central_point self.mark_point = mark_point self.graph = graph self.parent = graph self.angle = None if isinstance(angle, AngleMeasure): self.angle = angle else: if angle is not None: self.angle = AngleMeasure(value_degree=angle) self.dist = dist self.text = text self.position = position self.pspict = pspict if angle is not None: alpha = radian(angle) if isinstance(alpha, AngleMeasure): self.x = self.dist * cos(alpha.radian) self.y = self.dist * sin(alpha.radian) else: self.x = self.dist * cos(alpha) self.y = self.dist * sin(alpha)
def __init__(self, C, base, mx, Mx, pspict=None): ObjectGraph.__init__(self, self) self.C = C self.base = base self.mx = mx self.Mx = Mx self.pspict = pspict self.options = Options() self.IsLabel = False self.axes_unit = AxesUnit(self.base.length, "") self.Dx = 1 self.arrows = "->" self.graduation = True self.numbering = True self.imposed_graduation = [] self.mark_origin = True self.mark = None self.mark_angle = degree(base.angle().radian - pi / 2) self.enlarge_size = 0.5 # The `conclude` method performs the last computations before # to be drawn. The graduation bars are added there. self._already_concluded = False
def __init__(self, F, draw_points): ObjectGraph.__init__(self, F) GeometricVectorField.__init__(self, F.fx, F.fy) self.vector_field = F self.F = self.vector_field self.draw_points = draw_points