MATLAB Function Reference Previous page   Next Page
hgtransform

Create an hgtransform graphics object

Syntax

Description

h = hgtransform creates an hgtransform object and returns its handle.

h = hgtransform('PropertyName',PropertyValue,...) creates an hgtransform object with the property value settings specified in the argument list.

Hgtransform objects can contain other objects and thereby enable you to treat the hgtransform and its children as a single entity with respect to visibility, size, orientation, etc. You can group objects together by parenting them to a single hgtransform object (i.e., setting the object's Parent property to the hgtransform object's handle). For example,

The primary advantage of parenting objects to an hgtransform object is that it provides the ability to perform transformations (e.g., translation, scaling, rotation, etc.) on the child objects in unison.

An hgtransform object can be the parent of any number of axes children including other hgtransform objects.

The parent of an hgtransform object is either an axes object or another hgtransform.

Although you cannot see an hgtransform object, setting its Visible property to off makes all its children invisible as well.

More Information

Examples

Transforming a Group of Objects

This example shows how to create a 3-D star with a group of surface objects parented to a single hgtransform object. The hgtransform object is then rotated about the z-axis while its size is scaled.

  1. Create an axes and adjust the view. Set the axes limits to prevent auto limit selection during scaling.
  2. Create the objects you want to parent to the hgtransform object.
  3. Create an hgtransform object and parent the surface objects to it.
  4. Select a renderer and show the objects.
  5. Initialize the rotation and scaling matrix to the identity matrix (eye).
  6. Form the z-axis rotation matrix and the scaling matrix. Rotate 360 degrees (2*pi radians) and scale by using the increasing values of r.
  7. Reset to the original orientation and size using the identity matrix.

Transforming Objects Independently

This example creates two hgtransform objects to illustrate how each can be transformed independently within the same axes. One of the hgtransform objects has been moved (by translation) away from the origin.

  1. Create and set up the axes object that will be the parent of both hgtransform objects. Set the limits to accommodate the translated object.
  2. Create the surface objects to group.
  3. Create the hgtransform objects and parent them to the same axes.
  4. Set the renderer to use OpenGL.
  5. Parent the surfaces to hgtransform t1, then copy the surface objects and parent the copies to hgtransform t2.
  6. Translate the second hgtransform object away from the first hgtransform object and display the result.
  7. Rotate both hgtransform objects in opposite directions. Hgtransform t2 has already been translated away from the origin, so to rotate it about its z-axis you must first translate it to its original position. You can do this with the identity matrix (eye).

Setting Default Properties

You can set default hgtransform properties on the axes, figure, and root levels:

where PropertyName is the name of the hgtransform property and propertyvalue is the value you are specifying. Use set and get to access hgtransform properties.

See Also

hggroup, makehgtform

For more information about transforms, see Tomas Moller and Eric Haines, Real-Time Rendering, A K Peters, Ltd., 1999.

Group Objects for more information and examples.

Hgtransform Properties for property descriptions


Previous page  hgsave Hgtransform Properties Next page

© 1994-2005 The MathWorks, Inc.