Changeset 7971:66ae86c46978


Ignore:
Timestamp:
01/05/08 05:03:25 (5 years ago)
Author:
Robert Bradshaw <robertwb@…>
Branch:
default
Message:

Tachyon points/lines

Location:
sage/plot/plot3d
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sage/plot/plot3d/shapes2.py

    r7970 r7971  
    99 
    1010from texture import Texture 
     11 
     12TACHYON_PIXEL = 1/200.0 
    1113 
    1214from shapes import Text, Sphere 
     
    2729    if len(points) < 2: 
    2830        raise ValueError, "there must be at least 2 points" 
     31    for i in range(len(points)): 
     32        x, y, z = points[i] 
     33        points[i] = float(x), float(y), float(z) 
    2934    if radius is None: 
    3035        # make a zoom-invariant line 
    31         return Line(points, thickness=thickness, **kwds) 
     36        return Line(points, thickness=thickness, arrow_head=arrow_head, **kwds) 
    3237    else: 
    3338        v = [] 
     
    231236    def __init__(self, (x,y,z), size=1, **kwds): 
    232237        PrimitiveObject.__init__(self, **kwds) 
    233         self.loc = x, y, z 
     238        self.loc = float(x), float(y), float(z) 
    234239        self.size = size 
    235240         
     
    243248        else: 
    244249            cen = transform.transform_point(self.loc) 
    245         return "Sphere center %s %s %s Rad %s %s" % (cen[0], cen[1], cen[2], self.size, self.texture.id) 
     250        return "Sphere center %s %s %s Rad %s %s" % (cen[0], cen[1], cen[2], self.size * TACHYON_PIXEL, self.texture.id) 
    246251         
    247252    def jmol_repr(self, render_params): 
     
    293298        cmds = [] 
    294299        px, py, pz = self.points[0] if T is None else T(self.points[0]) 
     300        radius = self.thickness * TACHYON_PIXEL 
    295301        for P in self.points[1:]: 
    296302            x, y, z = P if T is None else T(P) 
    297             cmds.append("FCylinder base %s %s %s apex %s %s %s rad %s %s" % (px, py, pz, 
    298                                                                              x, y, z, 
    299                                                                              self.thickness, 
    300                                                                              self.texture.id)) 
     303            if self.arrow_head and P is self.points[-1]: 
     304                A = shapes.Arrow((px, py, pz), (x, y, z), radius = radius, texture = self.texture) 
     305                render_params.push_transform(~T) 
     306                cmds.append(A.tachyon_repr(render_params)) 
     307                render_params.pop_transform() 
     308            else: 
     309                cmds.append("FCylinder base %s %s %s apex %s %s %s rad %s %s" % (px, py, pz, 
     310                                                                                 x, y, z, 
     311                                                                                 radius, 
     312                                                                                 self.texture.id)) 
    301313            px, py, pz = x, y, z 
    302         print cmds 
    303314        return cmds 
    304315 
  • sage/plot/plot3d/transform.pyx

    r7967 r7971  
    108108        return Transformation(m = self.matrix * other.matrix) 
    109109         
     110    def __invert__(Transformation self): 
     111        return Transformation(m=~self.matrix) 
     112         
    110113    def __call__(self, p): 
    111114        return self.transform_point(p) 
     
    115118            self._svd = self.matrix.submatrix(0,0,3,3).SVD() 
    116119        return self._svd[1][0,0] 
     120 
     121    def avg_scale(self): 
     122        if self._svd is None: 
     123            self._svd = self.matrix.submatrix(0,0,3,3).SVD() 
     124        return (self._svd[1][0,0] * self._svd[1][1,1] * self._svd[1][2,2]) ** (1/3.0) 
    117125 
    118126 
Note: See TracChangeset for help on using the changeset viewer.