📄 z174.html
字号:
gnome_canvas_window_to_world</tt></code>(GnomeCanvas* <tt class="PARAMETER"><i>canvas</i></tt>, double <tt class="PARAMETER"><i>winx</i></tt>, double <tt class= "PARAMETER"><i>winy</i></tt>, double* <tt class= "PARAMETER"><i>worldx</i></tt>, double* <tt class= "PARAMETER"><i>worldy</i></tt>);</code> </p> <p> <code><code class="FUNCDEF">void <tt class= "FUNCTION"> gnome_canvas_world_to_window</tt></code>(GnomeCanvas* <tt class="PARAMETER"><i>canvas</i></tt>, double <tt class="PARAMETER"><i>worldx</i></tt>, double <tt class="PARAMETER"><i>worldy</i></tt>, double* <tt class="PARAMETER"><i>winx</i></tt>, double* <tt class="PARAMETER"><i>winy</i></tt>);</code> </p> </div> <p> <b>Figure 2. Coordinate Conversions</b> </p> </div> </div> <div class="SECT2"> <h2 class="SECT2"> <a name="SEC-AFFINES">Affine Transformations</a> </h2> <p> An <i class="FIRSTTERM">affine</i> is a transformation matrix made up of six real numbers that can be <i class= "FIRSTTERM">applied</i> to an ordered pair. Depending on the contents of the affine, the point it is applied to can be: </p> <ul> <li> <p> <i class="FIRSTTERM">translated</i>---shifted by an arbitrary distance in either dimension; </p> </li> <li> <p> <i class="FIRSTTERM">rotated</i> some number of degrees; </p> </li> <li> <p> <i class="FIRSTTERM">scaled</i> by some factor. </p> </li> </ul> <p> Conceptually, an affine defines a relationship between points on a plane. For any point (A,B), the affine defines a single corresponding transformed point; the mapping is one-to-one, so given the transformed point you can determine the original point. </p> <p> Affines have interesting properties that make them useful in computer graphics. Most importantly, they can be <i class="FIRSTTERM">composed</i>, <i class="FIRSTTERM"> concatenated</i>, or <i class="FIRSTTERM">multiplied</i> (the three terms are synonymous). You can compose any number of affines to create a single affine; applying the single affine has the same effect as applying each of the original affines in order. Note that the order of composition is important! Unlike multiplication, affine composition is not commutative (which is a reason to avoid the term "multiply" in this context). </p> <p> <tt class="APPLICATION">libart_lgpl</tt> contains a module for affine manipulation. It represents affines as an array of six doubles. Its affine functions are shown in <a href="z174.html#FL-AFFINES">Figure 3</a>. </p> <div class="FIGURE"> <a name="FL-AFFINES"></a> <div class="FUNCSYNOPSIS"> <a name="FL-AFFINES.SYNOPSIS"></a> <table border="0" bgcolor="#E0E0E0" width="100%"> <tr> <td><pre class="FUNCSYNOPSISINFO"> #include <libart_lgpl/art_affine.h> </pre> </td> </tr> </table> <p> <code><code class="FUNCDEF">void <tt class= "FUNCTION">art_affine_point</tt></code>(ArtPoint* <tt class="PARAMETER"><i>dst</i></tt>, const ArtPoint* <tt class="PARAMETER"><i>src</i></tt>, const double <tt class="PARAMETER"><i>affine[6]</i></tt>);</code> </p> <p> <code><code class="FUNCDEF">void <tt class= "FUNCTION">art_affine_invert</tt></code>(double <tt class="PARAMETER"><i>dst_affine[6]</i></tt>, const double <tt class="PARAMETER"><i> src_affine[6]</i></tt>);</code> </p> <p> <code><code class="FUNCDEF">void <tt class= "FUNCTION">art_affine_multiply</tt></code>(double <tt class="PARAMETER"><i>dst[6]</i></tt>, const double <tt class="PARAMETER"><i>src1[6]</i></tt>, const double <tt class="PARAMETER"><i> src2[6]</i></tt>);</code> </p> <p> <code><code class="FUNCDEF">void <tt class= "FUNCTION">art_affine_identity</tt></code>(double <tt class="PARAMETER"><i>dst[6]</i></tt>);</code> </p> <p> <code><code class="FUNCDEF">void <tt class= "FUNCTION">art_affine_scale</tt></code>(double <tt class="PARAMETER"><i>dst[6]</i></tt>, double <tt class="PARAMETER"><i>sx</i></tt>, double <tt class= "PARAMETER"><i>sy</i></tt>);</code> </p> <p> <code><code class="FUNCDEF">void <tt class= "FUNCTION">art_affine_rotate</tt></code>(double <tt class="PARAMETER"><i>dst[6]</i></tt>, double <tt class="PARAMETER"><i>theta</i></tt>);</code> </p> <p> <code><code class="FUNCDEF">void <tt class= "FUNCTION">art_affine_translate</tt></code>(double <tt class="PARAMETER"><i>dst[6]</i></tt>, double <tt class="PARAMETER"><i>tx</i></tt>, double <tt class= "PARAMETER"><i>ty</i></tt>);</code> </p> <p> <code><code class="FUNCDEF">int <tt class="FUNCTION"> art_affine_rectilinear</tt></code>(const double <tt class="PARAMETER"><i>src[6]</i></tt>);</code> </p> </div> <p> <b>Figure 3. Affine Manipulation</b> </p> </div> <p> <tt class="FUNCTION">art_affine_point()</tt> applies an affine to a point. The affine is applied to the second argument (<span class="STRUCTNAME">src</span>) and the result is copied into the first argument (<span class= "STRUCTNAME">dst</span>). An <span class="STRUCTNAME"> ArtPoint</span> is simply: </p> <table border="0" bgcolor="#E0E0E0" width="100%"> <tr> <td><pre class="PROGRAMLISTING"> typedef struct _ArtPoint ArtPoint;struct _ArtPoint { double x, y;}; </pre> </td> </tr> </table> <p> Affines can be <i class="FIRSTTERM">inverted</i>. If an affine converts points in coordinate system A into points in coordinate system B, its inverse converts points in coordinate system B into points in coordinate system A. <tt class="FUNCTION">art_affine_invert()</tt> fills its first argument with the inverse of its second. </p> <p> <tt class="FUNCTION">art_affine_multiply()</tt> composes two affines as described earlier in this section, placing the result in its first argument. </p> <p> Four functions are provided to create affines with particular properties. </p> <ul> <li> <p> <tt class="FUNCTION">art_affine_identity()</tt> creates the identity affine. Applying the identity affine to a point has no effect. </p> </li> <li> <p> <tt class="FUNCTION">art_affine_rotate()</tt> gives an affine that rotates points by <span class= "STRUCTNAME">theta</span> degrees. </p> </li> <li> <p> <tt class="FUNCTION">art_affine_translate()</tt> gives an affine that translates points <span class= "STRUCTNAME">tx</span> in the X dimension and <span class="STRUCTNAME">ty</span> in the Y dimension. </p> </li> <li> <p> <tt class="FUNCTION">art_affine_scale()</tt> gives an affine which scales the plane by the given factors (a factor of 1.0 does no scaling, less than 1.0 shrinks, greater than 1.0 expands). </p> </li> </ul> <p> <tt class="FUNCTION">art_affine_rectilinear()</tt> returns <span class="STRUCTNAME">TRUE</span> if the affine rotates rectangles aligned to the axes in such a way that they remain aligned to the axes. That is, it returns <span class="STRUCTNAME">TRUE</span> if the rotation is 0, 90, 180, or 270 degrees. </p> <p> You can ask the canvas widget to compute affines which convert between its various coordinate systems. These functions are shown in <a href= "z174.html#FL-CANVAS-AFFINES">Figure 4</a>; each of them fills an array you pass in with the affine being requested. </p> <div class="FIGURE"> <a name="FL-CANVAS-AFFINES"></a> <div class="FUNCSYNOPSIS"> <a name="FL-CANVAS-AFFINES.SYNOPSIS"></a> <table border="0" bgcolor="#E0E0E0" width="100%"> <tr> <td><pre class="FUNCSYNOPSISINFO"> #include <libgnomeui/gnome-canvas.h> </pre> </td> </tr> </table> <p> <code><code class="FUNCDEF">void <tt class= "FUNCTION"> gnome_canvas_item_i2w_affine</tt></code>(GnomeCanvasItem* <tt class="PARAMETER"><i>item</i></tt>, double <tt class="PARAMETER"><i>affine[6]</i></tt>);</code> </p> <p> <code><code class="FUNCDEF">void <tt class= "FUNCTION"> gnome_canvas_item_i2c_affine</tt></code>(GnomeCanvasItem* <tt class="PARAMETER"><i>item</i></tt>, double <tt class="PARAMETER"><i>affine[6]</i></tt>);</code> </p> <p> <code><code class="FUNCDEF">void <tt class= "FUNCTION"> gnome_canvas_w2c_affine</tt></code>(GnomeCanvas* <tt class="PARAMETER"><i>canvas</i></tt>, double <tt class="PARAMETER"><i>affine[6]</i></tt>);</code> </p> </div> <p> <b>Figure 4. Canvas Affines</b> </p> </div> </div> </div> <div class="NAVFOOTER"> <br> <br> <table width="100%" border="0" bgcolor="#ffffff" cellpadding= "1" cellspacing="0"> <tr> <td width="25%" bgcolor="#ffffff" align="left"> <a href="cha-canvas.html"><font color="#0000ff" size= "2"><b><<< Previous</b></font></a> </td> <td width="25%" colspan="2" bgcolor="#ffffff" align= "center"> <font color="#0000ff" size="2"><b><a href="ggad.html"> <font color="#0000ff" size="2"><b> Home</b></font></a></b></font> </td> <td width="25%" bgcolor="#ffffff" align="right"> <a href="z177.html"><font color="#0000ff" size="2"><b> Next >>></b></font></a> </td> </tr> <tr> <td colspan="2" align="left"> <font color="#000000" size="2"><b><tt class= "CLASSNAME">GnomeCanvas</tt></b></font> </td> <td colspan="2" align="right"> <font color="#000000" size="2"><b>Using the Canvas</b></font> </td> </tr> </table> </div> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -