<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">John & Andreas,<br>
<br>
I think what John is stating is that STL needs world coordinates
for everything. That means transforming every coordinate to world
space prior to conversion. Since X3D supports skewing (non-uniform
and non-axial scaling), you will need to use 4x4 matrices. I have
seen math libraries in X3DOM as Andreas has pointed out. THREE.js
also deals with quaternions (see
<a class="moz-txt-link-freetext" href="https://threejs.org/docs/index.html#api/math/Quaternion">https://threejs.org/docs/index.html#api/math/Quaternion</a> -- link at
bottom to code). It also has methods to return the world transform
(see <a class="moz-txt-link-freetext" href="https://threejs.org/docs/index.html#api/core/Object3D">https://threejs.org/docs/index.html#api/core/Object3D</a> for
.matrixWorld and related methods).<br>
<br>
Leonard Daly<br>
<br>
<br>
</div>
<blockquote type="cite"
cite="mid:CAGC3UEkd8BuRGF6FO2zpBSqJwgJMepy=gXEwXVUVnLe-NfVO_A@mail.gmail.com">
<div dir="auto">What I need for STL is to unwind all the
transforms into actual coordinates. STL has no concept of
transforms.
<div dir="auto"><br>
</div>
<div dir="auto">John</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Mon, Jun 4, 2018, 8:47 AM Andreas Plesch <<a
href="mailto:andreasplesch@gmail.com" moz-do-not-send="true">andreasplesch@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">x3dom has a
pretty complete matrix et al. math library which includes<br>
quaternions:<br>
<br>
<a
href="https://github.com/x3dom/x3dom/blob/master/src/fields.js#L1754"
rel="noreferrer noreferrer" target="_blank"
moz-do-not-send="true">https://github.com/x3dom/x3dom/blob/master/src/fields.js#L1754</a><br>
<br>
Its invert methods looks the same as yours.<br>
<br>
I am not sure if inverting a quaternions is identical to
inverting the<br>
4x4 rotation matrix derived from a quaternion, or if that is
what you<br>
need for stl.<br>
<br>
-Andreas<br>
<br>
> Date: Mon, 4 Jun 2018 03:18:40 -0400<br>
> From: John Carlson <<a
href="mailto:yottzumm@gmail.com" target="_blank"
rel="noreferrer" moz-do-not-send="true">yottzumm@gmail.com</a>><br>
> To: X3D Graphics public mailing list <<a
href="mailto:x3d-public@web3d.org" target="_blank"
rel="noreferrer" moz-do-not-send="true">x3d-public@web3d.org</a>><br>
> Subject: Re: [x3d-public] errors in convertJsonToStl.js<br>
> Message-ID: <<a
href="mailto:5b14e7cf.1c69fb81.b0537.d319@mx.google.com"
target="_blank" rel="noreferrer" moz-do-not-send="true">5b14e7cf.1c69fb81.b0537.d319@mx.google.com</a>><br>
> Content-Type: text/plain; charset="utf-8"<br>
><br>
> 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).<br>
><br>
> 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.<br>
><br>
> John<br>
><br>
><br>
> Sent from Mail for Windows 10<br>
><br>
> From: John Carlson<br>
> Sent: Saturday, May 20, 2017 2:20 AM<br>
> To: Don Brutzman; X3D Graphics public mailing list<br>
> Subject: RE: errors in convertJsonToStl.js<br>
><br>
> New versions of X3D JSON, STL and PLY interoperability
are here:<br>
><br>
> <a
href="https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertJsonToStl.js"
rel="noreferrer noreferrer" target="_blank"
moz-do-not-send="true">https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertJsonToStl.js</a><br>
> <a
href="https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertPlyToJson.js"
rel="noreferrer noreferrer" target="_blank"
moz-do-not-send="true">https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertPlyToJson.js</a><br>
> <a
href="https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertStlToJson.js"
rel="noreferrer noreferrer" target="_blank"
moz-do-not-send="true">https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertStlToJson.js</a><br>
><br>
> This mostly works with Indexed geometry.? I don?t handle
PLY texture coordinates yet.<br>
><br>
> Contributions are welcome, particularly JSON to PLY?<br>
><br>
> John<br>
><br>
><br>
> -------------- next part --------------<br>
> An HTML attachment was scrubbed...<br>
> URL: <<a
href="http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180604/ce73dc01/attachment-0001.html"
rel="noreferrer noreferrer" target="_blank"
moz-do-not-send="true">http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180604/ce73dc01/attachment-0001.html</a>><br>
><br>
> ------------------------------<br>
><br>
> Message: 3<br>
> Date: Mon, 4 Jun 2018 06:48:24 -0400<br>
> From: John Carlson <<a
href="mailto:yottzumm@gmail.com" target="_blank"
rel="noreferrer" moz-do-not-send="true">yottzumm@gmail.com</a>><br>
> To: X3D Graphics public mailing list <<a
href="mailto:x3d-public@web3d.org" target="_blank"
rel="noreferrer" moz-do-not-send="true">x3d-public@web3d.org</a>><br>
> Subject: Re: [x3d-public] errors in convertJsonToStl.js<br>
> Message-ID: <<a
href="mailto:5b1518f7.1c69fb81.ed8cb.38a4@mx.google.com"
target="_blank" rel="noreferrer" moz-do-not-send="true">5b1518f7.1c69fb81.ed8cb.38a4@mx.google.com</a>><br>
> Content-Type: text/plain; charset="utf-8"<br>
><br>
> 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).<br>
><br>
> <a
href="https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/matrix.js"
rel="noreferrer noreferrer" target="_blank"
moz-do-not-send="true">https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/matrix.js</a><br>
> <a
href="https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertJsonToStl.js"
rel="noreferrer noreferrer" target="_blank"
moz-do-not-send="true">https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertJsonToStl.js</a><br>
><br>
> search for quaternion.<br>
><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/<a
href="http://www.web3d.org/x3d/content/examples/Savage/"
rel="noreferrer noreferrer" target="_blank"
moz-do-not-send="true">www.web3d.org/x3d/content/examples/Savage/</a>?
(set up Cygwin/MingW, node.js etc, create symbolic link).<br>
><br>
> 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.<br>
><br>
> 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).<br>
><br>
> Thanks,<br>
><br>
> John<br>
><br>
><br>
> Sent from Mail for Windows 10<br>
><br>
> From: John Carlson<br>
> Sent: Monday, June 4, 2018 3:18 AM<br>
> To: X3D Graphics public mailing list<br>
> Subject: RE: errors in convertJsonToStl.js<br>
><br>
> 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).<br>
><br>
> 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.<br>
><br>
> John<br>
><br>
><br>
> Sent from Mail for Windows 10<br>
><br>
> From: John Carlson<br>
> Sent: Saturday, May 20, 2017 2:20 AM<br>
> To: Don Brutzman; X3D Graphics public mailing list<br>
> Subject: RE: errors in convertJsonToStl.js<br>
><br>
> New versions of X3D JSON, STL and PLY interoperability
are here:<br>
><br>
> <a
href="https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertJsonToStl.js"
rel="noreferrer noreferrer" target="_blank"
moz-do-not-send="true">https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertJsonToStl.js</a><br>
> <a
href="https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertPlyToJson.js"
rel="noreferrer noreferrer" target="_blank"
moz-do-not-send="true">https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertPlyToJson.js</a><br>
> <a
href="https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertStlToJson.js"
rel="noreferrer noreferrer" target="_blank"
moz-do-not-send="true">https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertStlToJson.js</a><br>
><br>
> This mostly works with Indexed geometry.? I don?t handle
PLY texture coordinates yet.<br>
><br>
> Contributions are welcome, particularly JSON to PLY?<br>
><br>
> John<br>
><br>
><br>
><br>
> -------------- next part --------------<br>
> An HTML attachment was scrubbed...<br>
> URL: <<a
href="http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180604/606f3c80/attachment.html"
rel="noreferrer noreferrer" target="_blank"
moz-do-not-send="true">http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180604/606f3c80/attachment.html</a>><br>
><br>
> ------------------------------<br>
><br>
> Subject: Digest Footer<br>
><br>
> _______________________________________________<br>
> x3d-public mailing list<br>
> <a href="mailto:x3d-public@web3d.org" target="_blank"
rel="noreferrer" moz-do-not-send="true">x3d-public@web3d.org</a><br>
> <a
href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org"
rel="noreferrer noreferrer" target="_blank"
moz-do-not-send="true">http://web3d.org/mailman/listinfo/x3d-public_web3d.org</a><br>
><br>
><br>
> ------------------------------<br>
><br>
> End of x3d-public Digest, Vol 111, Issue 6<br>
> ******************************************<br>
<br>
<br>
<br>
-- <br>
Andreas Plesch<br>
Waltham, MA 02453<br>
</blockquote>
</div>
<!--'"--><br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
x3d-public mailing list
<a class="moz-txt-link-abbreviated" href="mailto:x3d-public@web3d.org">x3d-public@web3d.org</a>
<a class="moz-txt-link-freetext" href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org">http://web3d.org/mailman/listinfo/x3d-public_web3d.org</a>
</pre>
</blockquote>
<p><br>
</p>
<div class="moz-signature">-- <br>
<font class="tahoma,arial,helvetica san serif" color="#333366">
<font size="+1"><b>Leonard Daly</b></font><br>
3D Systems & Cloud Consultant<br>
LA ACM SIGGRAPH Past Chair<br>
President, Daly Realism - <i>Creating the Future</i>
</font></div>
</body>
</html>