Hello everybody!
I would like create POINTS in different UCS with the function acdbEntMake ().
But I have serious troubles in calculation the correct angle for the GC 50. POINTS do not have an own OCS/ECS. I have the correct values of UCSXDIR, UCSYDIR and the vector for the GC 210. But what is the correct algorithm for calculating the angle in GC 50.
Thank you very much and many greetings.
LV
Solved! Go to Solution.
Solved by tbrammer. Go to Solution.
Use AcGePoint3d::transformBy.
you can convert RT3DPOINT to/from AcGePoint3d using asDblArray() and asPnt3d() functions
This should work:
double EcsRotation(const AcGeVector3d &ucsXdir, const AcGeVector3d &ucsYdir) {
AcGeVector3d ucsZdir = ucsXdir.crossProduct(ucsYdir);
AcGeVector3d zPerp(ucsZdir.perpVector());
return ucsXdir.angleTo(zPerp, ucsZdir);
}
double EcsRotation(AcDbDatabase* pDB) {
return EcsRotation(pDB->ucsxdir(), pDB->ucsydir());
}
Dear 'tbrammer': Thank you very much! It works great! One last question: if I wand to insert a simple text-entity in a ucs (using ocs/ecs) it needs a different angle as gc 50. Have you any idea? Looking forward. Many greetings!
Why do you think text and point entities use different angles? I tried to create texts and points in different UCSs and found the GC 50 values to be just the same for both.
But in fact point entities behave different than other entities when they are rotated around arbitrary axes. Their GC 50 / Z-rotation value is not calculated correctly. See this screencast.
Hello,
indeed, a point and a text have in the same UCS with 0 inserting rotation-angle different GC50. See the following pictures.
Nevertheless the angle in GC50 for Text-Entities I use the following code:
// Einheitsvektor X-Achse WCS
x_wcs[X]=1.0; x_wcs[Y]=0.0; x_wcs[Z]=0.0;
// Einheitsvektor Y-Achse WCS
z_wcs[X]=0.0; z_wcs[Y]=0.0; z_wcs[Z]=1.0;
// UCS-Mode
if (dgm->ucs_mode==true) {
// Z-Achse UCS
acdbUcs2Wcs (z_wcs, dgm->ucs_zdir,true);
// Setzen des GC für TEXT
acdbWcs2Ucs (z_wcs, z_ucs, true);
acdbWcs2Ucs (x_wcs, x_ucs, true);
p1[X]=0.0; p1[Y]=0.0;
if ((fabsl(z_ucs[X])+fabsl(z_ucs[Y]))<DBL_EPSILON) { // Z-Achse-UCS zu Z-Achse WCS parallel
p2[X]=x_ucs[X]; p2[Y]=x_ucs[Y];
dgm->ucs_tang = -acutAngle (p1, p2);
}
else {
p2[X]=z_ucs[X]; p2[Y]=z_ucs[Y];
dgm->ucs_tang = 2*M_PI-acutAngle (p1, p2)+M_PI_2;
}
}
So, everything is fine! Thank you to all of you and many greetings!
Can't find what you're looking for? Ask the community or share your knowledge.