Object Manipulation
Previous Topic  Next Topic 

 

Object Transformation

 

You can transform an object by using the following method:

 

Object.Move()

Object.Rotate()

Object.Scaling()

Object.ApplyMatrix()

 

sdLwPolyline poly = seeDrawCtrl1.Document.AddLwPolyline();

            poly.AddVertex(new Point3D(0, 0, 0));

            poly.AddVertex(new Point3D(10, 0, 0));

            poly.AddVertex(new Point3D(10, 10, 0));

 

Object.Move()

// Move the entities to the position of (10,0,0)

poly.Move(new Point3D(10, 0, 0));

 

Object.Rotate()

// Rotate the entities 45 degree about the Z-Axis.

// The rotation axis is defined by two Point3D the First point - Second point.

poly.Rotate(new Point3D(0,0,1),new Point3D(0,0,0),45);

 

Object.Scaling()

// Scaling the entities uniformly with each scaling parameter set to 2 with respect to a selected fixed position (0,0,0).

// the user may specified a selected fixed position at a position other than origin.

poly.Scaling(2, 2, 2, new Point3D(0, 0, 0));

 

Object.ApplyMatrix()

 

// Create a new matrix object.

sdMatrix matrix = new sdMatrix();

// Set this matrix to Identity matrix.

matrix.SetIdentity();

// Apply a translation to this matrix.

matrix.Translate(10, 0, 0);

// Applies a rotation by a an angle about the specified 3D axis to this matrix.  

// The axis of rotation is defined by P2-P1;

matrix.Rotate(new Point3D(0, 0, 1), new Point3D(0, 0, 0), 45);

// Applies the specified scale to this matrix with respect to a seleted fixed position.

matrix.Scale(2, 2, 2, new Point3D(0, 0, 0));

// Transform this object by the specified matrix.

poly.ApplyMatrix(matrix);

 

// Regenerate the entities.

poly.Regen();

 

 

 

Moving the vertex of an object

 

The vertex of an object can be moved by two method Object.SetWorldVertex and Object.SetWindowVertex.

 

Object.SetWorldVertex

// Set the vertex to the location as specified by the 3D world coordinate.

poly.SetWorldVertex(0, new Point3D(20, 0, 0));

 

Object.SetWindowVertex

// Set the vertex to the location as specified by the 2D window coordinate.

poly.SetWindowVertex(0, new Point2D(0, 0));

 

 

 

Add and Remove vertex from an object

 

The user are allow to Add or Remove a vertex by using the method AddVertex

and RemoveVertexAt.

 

// Add vertex 

poly.AddVertex(new Point3D(0, 0, 0));

// Remove the vertex at the index 1 of the VertexList.

poly.RemoveVertexAt(1);

 

Do not add or remove the vertex directly from the VertexList collection of an object!

 

 

 

Copy or Duplicate an object.

 

object.Clone() method will duplicate the object and return to the user.

 

 

 

How to retrieve the bounding box of an object.

 

sdBox box = poly.GetBoundingBox();