Example of CADMatrix

If you have any comments or questions about our developing tools, please do not hesitate to contact us at this forum

Moderators: admin, SDS, support

Example of CADMatrix

Postby ldelvalle » 22 Jun 2012, 09:57

Hello

I do not understand the structure of the array (CADMatrix.data). Is an array of 16 elements do not understand the correspondence with the transformation matrices. In another example of this forum refers to a 2x2 matrix. Could you give an example of rotation, scaling and translation with CADMatrix?

My intention is to apply transformations rotation, scaling and translation to an entity and that is reflected in their original coordinates. If the transformation applied to the object CADImage this is not reflected in these coordinates.

Thank you very much, greetings.
ldelvalle
 
Posts: 3
Joined: 22 Jun 2012, 09:50
Location: Spain

Re: Example of CADMatrix

Postby support » 26 Jun 2012, 14:05

Hello.
Entities on drawing can be conditionally sorted on two groups. The first group includes entities defined by points/vertexes, for example CADLine, CADPolyLine and CADSpline. Other entities, like CADText, CADInsert or CADImageEnt defined by insertion point and other properties.
CADMatrix class can be used to apply transformations to a single entity. For the entities from the first group each point/entity must be multiplied by matrix object. Entities from second group provide different properties like Scale or Angle to transform. The insertion point can be affected by matrix.
The following example shows scaling and rotation of a line. Rotation can be completed also around any other point.
Code: Select all
    {   
        CADLine line = (CADLine)cadImage.Converter.Entities[0];

        // scale
        CADMatrix matrix = new CADMatrix();
        double scaleX = 2.0;
        double scaleY = 1.5;
        double scaleZ = 3.4;
        matrix[0, 0] = scaleX;
        matrix[1, 1] = scaleY;
        matrix[2, 2] = scaleZ;

        line.Point = PointXmat(line.Point, matrix);
        line.Point1 = PointXmat(line.Point1, matrix);

        cadImage.Converter.Loads(line);
        //end of scale

        //rotate around (0, 0)
        CADMatrix matrix = new CADMatrix();
        double angle = 15;
        matrix[0, 0] = Math.Cos(Math.PI * angle / 180);
        matrix[0, 1] = Math.Sin(Math.PI * angle / 180);
        matrix[1, 0] = -matrix[0, 1];
        matrix[1, 1] = matrix[0, 0];

        line.Point = PointXmat(line.Point, matrix);
        line.Point1 = PointXmat(line.Point1, matrix);

        cadImage.Converter.Loads(line);
        //end of rotation
    }

    private DPoint PointXmat(DPoint pt, CADMatrix mat)
    {
        DPoint result;
        result.X = pt.X * mat[0, 0] + pt.Y * mat[1, 0] + pt.Z * mat[2, 0] + mat[3, 0];
        result.Y = pt.X * mat[0, 1] + pt.Y * mat[1, 1] + pt.Z * mat[2, 1] + mat[3, 1];
        result.Z = pt.X * mat[0, 2] + pt.Y * mat[1, 2] + pt.Z * mat[2, 2] + mat[3, 2];

        return result;
    }

Unfortunately translation of an entity isn't clear to us. Please specify what did you mean by this term.

Alexander.
Please post questions to the forum or write to support@cadsofttools.com
support
 
Posts: 2226
Joined: 30 Mar 2005, 08:36
Location: Russia

Re: Example of CADMatrix

Postby ldelvalle » 29 Jun 2012, 09:37

Thank you very much for the information. What he meant by "translate" the entity is transferred to other coordinates. Sorry for my English is not very good :-).

We are evaluating your framework and it really is a very powerful, we are loving it.

I have been all very clear, like water :-).

Luis.
ldelvalle
 
Posts: 3
Joined: 22 Jun 2012, 09:50
Location: Spain

Re: Example of CADMatrix

Postby ldelvalle » 05 Jul 2012, 11:29

Hello

When transforming the coordinates for entities circle, arc and spline, I use the PolyPoints and I declare an CADLWPolyLine these points. My question is I can increase resulción of those points and how to can I do?

My goal is to reduce or increase PolyPoints of any entity.

Thank you very much, greetings.
ldelvalle
 
Posts: 3
Joined: 22 Jun 2012, 09:50
Location: Spain

Re: Example of CADMatrix

Postby support » 09 Jul 2012, 13:24

Hello.
CADImage.Converter.NumberOfPartsInCircle affects circles and arcs, CADImage.Converter.NumberOfPartsInSpline affcts splines.

Alexander.
Please post questions to the forum or write to support@cadsofttools.com
support
 
Posts: 2226
Joined: 30 Mar 2005, 08:36
Location: Russia


Return to CADImport.NET + DXFExport.NET

Who is online

Users browsing this forum: No registered users and 1 guest

cron