Page 1 of 1
Example of CADMatrix
Posted: 22 Jun 2012, 12:57
by ldelvalle
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.
Re: Example of CADMatrix
Posted: 26 Jun 2012, 17:05
by support
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.
Re: Example of CADMatrix
Posted: 29 Jun 2012, 12:37
by ldelvalle
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.
Re: Example of CADMatrix
Posted: 05 Jul 2012, 14:29
by ldelvalle
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.
Re: Example of CADMatrix
Posted: 09 Jul 2012, 16:24
by support
Hello.
CADImage.Converter.NumberOfPartsInCircle affects circles and arcs, CADImage.Converter.NumberOfPartsInSpline affcts splines.
Alexander.