Hi Sage-Devel,

There are some inconsistencies with the behavior of aspect ratio when
playing with 2D and 3D graphics. Here are examples that illustrate
these.

2D :
===

sage: squareA = line([(0,0),(0,1),(1,1),(1,0),(0,0)])
sage: squareB = line([(3,7),(3,8),(4,8),(4,7),(3,7)])
sage: G = squareA + squareB

The default aspect ratio is the golden number. So by default, squares
look like rectangle :

sage: G

To make squares look like square, one must change the aspect ratio to
the value = 1.

sage: G.aspect_ratio()                     # getter method, returns
None by default
sage: G.set_aspect_ratio(1)            # setter method, takes an
number (no 2d tuple)
sage: G.aspect_ratio()
1.0
sage: G




3D :
===

In 3d, the default aspect ratio is [1,1,1]. However, cube do not look like cube:

sage: G = cube((10,5,3)) + cube((-7,-3,0))
sage: G.aspect_ratio()
[1.0, 1.0, 1.0]
sage: G

So, one can change the aspect ratio to something else, but this
doesn't have any effect on the 3D Graphic shown in Jmol:

sage: G.aspect_ratio((100,1,1))            # in 3d, this method is the
getter AND the setter
sage: G.aspect_ratio()
[100.0, 1.0, 1.0]
sage: G

Is there another goal for 3D aspect_ratio method?

One see the existence of the frame_aspect_ratio method whose value is
independant of the aspect_ratio. By default, the frame aspect ratio is
[1, 1, 1]. Changing the frame aspect ratio has an effect on the 3d
Graphic object.

sage: G.frame_aspect_ratio()            # setter and getter method
(inexistant in 2d)
[1.0, 1.0, 1.0]
sage: G.frame_aspect_ratio((100,1,1))
sage: G.frame_aspect_ratio()
[100.0, 1.0, 1.0]
sage: G

To draw cube that looks like cube, one must do:

sage: G.bounding_box()
((-7.5, -3.5, -0.5), (10.5, 5.5, 3.5))
sage: a,b = map(vector, G.bounding_box())
sage: G.frame_aspect_ratio(tuple(b-a))
sage: G.frame_aspect_ratio()
[18.0, 9.0, 4.0]
sage: G

I think it would be a good thing if the behavior of aspect ratio was
uniformized for 2D and 3D graphics.

Meanwhile, do you know a oneliner (simpler than the one above) that
draw 3d graphics object with aspect ratio 1, i.e. where cube looks
like cube?

Thank you,

Sébastien

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to