Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
I'm trying to write a LISP function to let me add Coordinate Systems with Body Euler Sequences using Pitch, Yaw, Roll.
So far I can create a coordinate system and set an offset it, but I can't seem to rotate it using LISP calls.
Is this even close or is there a something completely different that does the same thing?
Thanks,
Damion
(use-package :oli)
(defun create-cs-pyr (frame-name owner-path parent-cs x y z pitch yaw roll)
(let ( (frame-path nil) (frame-obj nil)(origin nil) (x-dir nil) (y-dir nil) (z-dir nil))
(pos_create_coordinate_system :owner owner-path :name frame-name :u_name "x" :v_name "y"
:w_name "z" :by_ref_coord_sys :ref_coord_sys parent-cs :offset_u x :offset_v y :offset_w z
:done)
(complete)
(setq frame-path (concatenate 'string owner-path "/" frame-name))
(setq frame-obj (sd-pathname-to-obj frame-path))
(setq origin (getf (sd-inq-coord-sys-elem-value frame-obj :origin t ) :origin))
(setq y-dir (getf (sd-inq-coord-sys-elem-value frame-obj :y-axis t ) :y-axis))
;; How to get this to work or something similar? Once the coordinate system is rotated about the y-axis (Pitch), I'd like to query the new orientation and
;; do the yaw and roll?
(pos_create_coordinate_system :action :position :coord_sys frame-obj :rotate :axis :pt_dir origin (second y-dir) :rotation_angle (sd-deg-to-rad pitch) complete)
(setq z-dir (getf (sd-inq-coord-sys-elem-value frame-obj :z-axis t ) :z-axis ))
(setq x-dir (getf (sd-inq-coord-sys-elem-value frame-obj :x-axis t ) :x-axis ))
)
)
I'm having a similar problem in regular Pro/TOOLKIT. The functions to get transformations between coordinate systems (ProAsmcomppathTrfGet) return in transformatrices, not in angles... but the feature element tree for angles require rotations in degrees. Could use any input if someone has background or advice.
Hi,
this is my function to convert a transformation to three angles......
Hope this helps.
Andreas
ProError tools_angles_from_transformation_get (ProMatrix hTransform, double *dRotX, double *dRotY, double *dRotZ)
{
double dX, dY, dZ;
long lY;
// calculate "Euler angles" from transformation:
if (hTransform[0][2]>1 || hTransform[0][2]<-1)
{
lY = (long)(-hTransform[0][2]*10000);
dY = asin ((double)(lY/10000));
}
else
dY = asin (-hTransform[0][2]);
if (fabs (dY) < (2*PI/4.0 - 0.0008))
{
dX = atan2 (hTransform[1][2], hTransform[2][2]);
dZ = atan2 (hTransform[0][1], hTransform[0][0]);
}
else
{
dX = 0.0;
dZ = atan2(-hTransform[1][0], hTransform[1][1]);
}
// rad to deg
dX = dX*180.0 / (6*asin(0.5));
dY = dY*180.0 / (6*asin(0.5));
dZ = dZ*180.0 / (6*asin(0.5));
*dRotX = dX;
*dRotY = dY;
*dRotZ = dZ;
return (PRO_TK_NO_ERROR);
}