Ticket #2859: trac-2859-arrow3d.patch

File trac-2859-arrow3d.patch, 2.4 KB (added by jason, 13 years ago)
  • sage/modules/free_module_element.pyx

    # HG changeset patch
    # User Jason Grout <jason-sage@creativetrax.com>
    # Date 1207730743 18000
    # Node ID f18d3a3a19d2957354277a18a94b4d7c26bb2f83
    # Parent  38f4b4ba3dd854e3fa30843703bc162dde901849
    [mq]: trac-2859-arrow3d.patch
    
    diff -r 38f4b4ba3dd8 -r f18d3a3a19d2 sage/modules/free_module_element.pyx
    a b  
    753753        INPUT:
    754754       
    755755            plot_type -- (default: 'arrow' if v has 3 or fewer components,
    756             otherwise 'step') type of plot.  Options are 'arrow' to an
     756            otherwise 'step') type of plot.  Options are 'arrow' to draw an
    757757            arrow; 'point' to draw a point at the coordinates
    758758            specified by the vector; 'step' to draw a step function
    759759            representing the coordinates of the vector.  Both 'arrow'
  • sage/plot/plot3d/shapes.pyx

    diff -r 38f4b4ba3dd8 -r f18d3a3a19d2 sage/plot/plot3d/shapes.pyx
    a b  
    339339        1
    340340        sage: type(a.all[0])
    341341        <type 'sage.plot.plot3d.shapes.Cone'>
     342
     343    Arrows are always constructed pointing up in the z direction from
     344    the origin, and then rotated/translated into place. This works for
     345    every arrow direction except the -z direction.  We take care of the
     346    anomoly by testing to see if the arrow should point in the -z
     347    direction, and if it should, just scaling the constructed arrow by
     348    -1 (i.e., every point is sent to its negative). The scaled arrow
     349    then points downwards. The doctest just tests that the scale of -1
     350    is applied to the arrow.
     351
     352        sage: a = arrow3d((0,0,0), (0,0,-1))
     353        sage: a.all[0].get_transformation().transform_point((0,0,1))
     354        (0.0, 0.0, -1.0)
    342355    """
    343356    if radius is None:
    344357        radius = thickness/50.0
     
    358371                + Cone(head_radius, head_len, **kwds).translate(0, 0, length-head_len)
    359372    axis = zaxis.cross_product(diff)
    360373    if axis == 0:
    361         return arrow.translate(start)
     374        if diff[2] >= 0:
     375            return arrow.translate(start)
     376        else:
     377            return arrow.scale(-1).translate(start)
    362378    else:
    363379        theta = -acos(diff[2]/length)
    364380        return arrow.rotate(axis, theta).translate(start)