<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style></head><body lang=EN-US link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Well, I “fixed” my code, but would appreciate a second pair of eyes looking at it.  Essentially, I added an inverse quaternion to the transform “stack” (now not quite a stack).</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><a href="https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/matrix.js">https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/matrix.js</a></p><p class=MsoNormal><a href="https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertJsonToStl.js">https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertJsonToStl.js</a></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>search for quaternion.</p><p class=MsoNormal><br>If you hook up the X3DJSONLD web server, you can search for “LightsOn” in X3DJSONLD and look at the JSON file  at /c/x3d-code/www.web3d.org/x3d/content/examples/Savage/… (set up Cygwin/MingW, node.js etc, create symbolic link).</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>It should convert to STL automatically I think. To convert back to JSON (and display as a green surface), press the here above the STL output pane.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>But really, just a review of the quaternion code should be sufficient.   There’s probably an issue with the viewpoint in the example (STL doesn’t have viewpoints, and I don’t think I’ve taken the time to introduce the necessary transforms).</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thanks,</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>John</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Sent from <a href="https://go.microsoft.com/fwlink/?LinkId=550986">Mail</a> for Windows 10</p><p class=MsoNormal><o:p> </o:p></p><div style='mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal style='border:none;padding:0in'><b>From: </b><a href="mailto:yottzumm@gmail.com">John Carlson</a><br><b>Sent: </b>Monday, June 4, 2018 3:18 AM<br><b>To: </b><a href="mailto:x3d-public@web3d.org">X3D Graphics public mailing list</a><br><b>Subject: </b>RE: errors in convertJsonToStl.js</p></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I looked at my quaternion code today, and at quaternions and rotations on the web.  I am not quite sure how I came up with the code I did (I saw some video). I think I watched the wrong video, or I was smoking anxiety that day.  Currently, my converter converts lots of stuff to a plane, it looks like (see SuperCobra).<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Can anyone point me to a reasonable open source implementation of quaternion rotations in JavaScript, Java, C or C++?  X_ITE or X3DOM? Ideally, the quaternions would fit into a 4x4 matrix stack, which is how I learned how to do transforms (I am not doing a perspective transform that I know of, so perhaps 3x3 is good enough).  Yes, I know that other implementations are probably more efficient. I’d like to try to get 4x4 transforms working first before optimizing.  4x4 transforms are NOT a requirement, however, just a nice to have.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>John<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Sent from <a href="https://go.microsoft.com/fwlink/?LinkId=550986">Mail</a> for Windows 10<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b>From: </b><a href="mailto:yottzumm@gmail.com">John Carlson</a><br><b>Sent: </b>Saturday, May 20, 2017 2:20 AM<br><b>To: </b><a href="mailto:brutzman@nps.edu">Don Brutzman</a>; <a href="mailto:x3d-public@web3d.org">X3D Graphics public mailing list</a><br><b>Subject: </b>RE: errors in convertJsonToStl.js<o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>New versions of X3D JSON, STL and PLY interoperability are here:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><a href="https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertJsonToStl.js">https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertJsonToStl.js</a><o:p></o:p></p><p class=MsoNormal><a href="https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertPlyToJson.js">https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertPlyToJson.js</a><o:p></o:p></p><p class=MsoNormal><a href="https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertStlToJson.js">https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertStlToJson.js</a><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>This mostly works with Indexed geometry.  I don’t handle PLY texture coordinates yet.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Contributions are welcome, particularly JSON to PLY…<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>John<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>