LDraw.org Discussion Forums
LDCad 1.6 suggestions/plans - Printable Version

+- LDraw.org Discussion Forums (https://forums.ldraw.org)
+-- Forum: LDraw Programs (https://forums.ldraw.org/forum-7.html)
+--- Forum: LDraw Editors and Viewers (https://forums.ldraw.org/forum-11.html)
+--- Thread: LDCad 1.6 suggestions/plans (/thread-18426.html)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20


Re: LDCad 1.6 ROTSTEP feedback - Roland Melkert - 2016-02-25

Roland Melkert Wrote:Also does anyone know the best/easiest way to extract the angles from an existing rotation matrix?
I think I solved this, but if anyone knows a better method...

Code:
void TLDStepMetaLine::getRotStepAngles(const TGLMatrixd &matrix, double &x, double  &y, double &z, const int roundTo) {

  x=atan2(matrix.array2D[2][1], matrix.array2D[2][2]);

  const double c2=sqrt(SQR(matrix.array2D[0][0])+SQR(matrix.array2D[1][0]));
  y=atan2(-matrix.array2D[2][0], c2);

  const double s1=sin(x);
  const double c1=cos(x);
  z=atan2(s1*matrix.array2D[0][2]-c1*matrix.array2D[0][1], c1*matrix.array2D[1][1]-s1*matrix.array2D[1][2]);

  //allemaal neg nav de sign flips in de ROTSTEP spec.
  x=-rad2Deg(x);
  y=-rad2Deg(y);
  z=-rad2Deg(z);

  if (roundTo>0)
  {
    x=((int)round(x/roundTo))*roundTo;
    y=((int)round(y/roundTo))*roundTo;
    z=((int)round(z/roundTo))*roundTo;
  }
};



Re: LDCad 1.6 ROTSTEP feedback - TestOne - 2016-02-25

I never used ROTSTEP, but about the question "Also does anyone know the best/easiest way to extract the angles from an existing rotation matrix?", attached you can find the Excel file I use to convert angles to matrix and vice versa (second sheet), plus some useful trigonometric formulas to estimate the angles to be applied to pieces (first sheet).

You can paste in B2 the rotation matrix copied from LDCad and see the results in the B13Big Grin15 range (choose the axis sequence you prefer), or obtain the resulting rotation matrix in B28, from the angles applied in the x-z-y order from the B19:B21 cells.

Note that the 2D arctangent in Excel uses the arguments in reversed order in respect to other programming languages and math bibliography.

I don't know if this is the easiest/best way to obtain them, I have no PhD in mathematics :-P
Ignore the round formula.

Hope this can help you

EDIT:
Oops, just saw you already found a solution.. I have not yet studied your formulas, but I have not seen a check condition for the +/-90 degrees singularity. Have you checked the rotation matrix 0 -1 0 1 0 0 0 0 1?


Re: LDCad 1.6 ROTSTEP feedback - Roland Melkert - 2016-02-25

TestOne Wrote:EDIT:
Oops, just saw you already found a solution.. I have not yet studied your formulas, but I have not seen a check condition for the +/-90 degrees singularity. Have you checked the rotation matrix 0 -1 0 1 0 0 0 0 1?
It gives x=0 y=0 z=90.

I applied this document in the extraction function.

I just needed to switch the matrix col/rows (due to OpenGL). And flipped the resulting angle signs to compensate for the minor differences in building the matrix in the first place as dictated by the ROTSTEP spec.

edit: used the wrong matrix to test, xyz values corrected.


Re: LDCad 1.6 suggestions/plans - AKGrannymom - 2016-03-01

I see instructions for starting Draw on a Mac but nothing on my computer will open Draw. What program do I need to open the file?


Re: LDCad 1.6 suggestions/plans - Jaco van der Molen - 2016-03-02

AKGrannymom Wrote:I see instructions for starting Draw on a Mac but nothing on my computer will open Draw. What program do I need to open the file?
Hi there,
For the Mac there is Bricksmith to open LDraw files.
See: http://bricksmith.sourceforge.net/


Re: LDCad 1.6 scripting preview clip - Roland Melkert - 2016-03-04

Hi all,

I've been working on the new scripting extensions now and then and would really like some feedback on the api / default tool/sample collection.

A short (~3 min) clip: https://youtu.be/xP-d-A6SmnE

The main script used in it does technic engine piston placement magic for the current model.

It also shows the new global animation feature.

Below is the source of the engine placement script, any thoughts suggestions are welcome.

edit: script as attachment as the bbcode messes with the [ i ] references.


Re: LDCad 1.6 scripting preview clip - Philippe Hurbain - 2016-03-05

The video is awesome (of course!)
As for the script... I was able to follow most of what happens here, but it's difficult for me to tell more without a bit of experimentation...


Re: LDCad 1.6 ROTSTEP feedback - Jaco van der Molen - 2016-03-05

Lovely!
Macro's look cool and very handy.
The explode is very nice too!


Re: LDCad 1.6 suggestions/plans - Jason Smith - 2016-03-05

Looks super impressive to me. Also a huge time saver especially for all those angles and such required for the piston placements.

Seems like your only a baby step away from hitting a button and making those pistons animate within in the cylinders?


Re: LDCad 1.6 suggestions/plans - Roland Melkert - 2016-03-05

Jason Smith Wrote:Seems like your only a baby step away from hitting a button and making those pistons animate within in the cylinders?
Yes only thing needed would be to keep track of the piston positions while the axle is rotating, then you could apply the same orientation calculations etc.

Maybe I'll add a new example model using that Smile