Changeset 5899:38a3bb3c0def
- Timestamp:
- 08/24/07 00:03:27 (6 years ago)
- Branch:
- default
- Children:
- 5900:d169f23c4cb4, 5936:bd86b75bcd21
- File:
-
- 1 edited
-
sage/plot/graphics3d.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sage/plot/graphics3d.py
r5898 r5899 15 15 """ 16 16 from random import randint 17 from math import atan2 17 18 18 19 from sage.structure.sage_object import SageObject … … 269 270 # rotate about v by theta 270 271 vx, vy, vz, theta = rot 271 if vz != 0: 272 t = atan(vy/vz) + pi/2 273 m = self.rotX(t) * m 274 new_y = vy*cos(t) - vz*sin(t) 275 else: 276 t = 0 277 new_y = vy 272 t = atan2(vy,vz) + pi/2 273 m = self.rotX(t) * m 274 new_y = vy*cos(t) - vz*sin(t) 278 275 # v = [vx, new_y, 0] 279 if new_y != 0: 280 s = atan(vx/new_y) + pi/2 281 m = self.rotZ(s) * m 282 else: 283 s = 0 276 s = atan2(vx,new_y) + pi/2 277 m = self.rotZ(s) * m 284 278 # v = [new_x, 0, 0] 285 279 m = self.rotX(theta) * m … … 483 477 Create a cylindar from start to end with radius radius. 484 478 """ 485 start = vector(RDF, start )486 end = vector(RDF, end )487 yaxis = vector(RDF, (0,1,0))479 start = vector(RDF, start, sparse=False) 480 end = vector(RDF, end, sparse=False) 481 zaxis = vector(RDF, (0,0,1), sparse=False) 488 482 diff = end - start 489 483 height = sqrt(diff.dot_product(diff)) 490 484 cyl = Cylinder(radius, height, **kwds) 491 axis = yaxis.cross_product(diff) 492 theta = -acos(yaxis.dot_product(diff)/height) 493 return cyl.rotate(axis, theta).translate(start) 494 485 axis = zaxis.cross_product(diff) 486 if axis == 0: 487 return cyl 488 else: 489 theta = -acos(diff[2]/height) 490 return cyl.rotate(axis, theta).translate(start) 495 491 496 492 class Sphere(PrimativeObject):
Note: See TracChangeset
for help on using the changeset viewer.
