<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to use vec2/3 classes]]></title><description><![CDATA[<p dir="auto">Hello, as I restarted using JSCAD, after a long time using only C language, then vanilla JS, I would like to know how to use the vec2/3 classes, what is the needed require, and how to use them. I remember I used such classes with V1 but with V2 I didn't and for exemple I have code where I need to compute a geometry dimensions and center, so I use<br />
b = measureBoundingBox()<br />
then the dimensions are b[1] minus b[0]<br />
and the center is b[1] minus dimensions' half<br />
For the moment I'm directly using the values from the returned array.</p>
]]></description><link>https://openjscad.nodebb.com/topic/399/how-to-use-vec2-3-classes</link><generator>RSS for Node</generator><lastBuildDate>Wed, 16 Sep 2026 04:05:09 GMT</lastBuildDate><atom:link href="https://openjscad.nodebb.com/topic/399.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 28 Feb 2023 16:58:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to use vec2/3 classes on Wed, 01 Mar 2023 22:40:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/gilboonet" aria-label="Profile: gilboonet">@<bdi>gilboonet</bdi></a> the example looks fine. You can create, rotate, transform all the math objects..</p>
<p dir="auto">Now comes the fun part... curves, distances, etc. There are little tidbits of logic throughout the library. You can find some of the basic calculations in the primitives, I.e. arc, circle, sphere, etc.</p>
<p dir="auto">And of course, let us know if you have questions.</p>
]]></description><link>https://openjscad.nodebb.com/post/1310</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/1310</guid><dc:creator><![CDATA[z3dev]]></dc:creator><pubDate>Wed, 01 Mar 2023 22:40:32 GMT</pubDate></item><item><title><![CDATA[Reply to How to use vec2/3 classes on Wed, 01 Mar 2023 10:34:09 GMT]]></title><description><![CDATA[<p dir="auto">Just to reply to my own question ...</p>
<pre><code>const jscad = require('@jscad/modeling')
const { sphere } = jscad.primitives
const { vec3 } = jscad.maths
const { translate } = jscad.transforms
 
const main = () =&gt; {
  let A = vec3.fromValues(15,0,5);
  console.log("A:", A);
  
  let B = vec3.create();
  
  vec3.add(B, A, [50,0,0]);
  
  console.log("B:", B);
  
  let C = vec3.create();
  vec3.add(C, A, B);
  vec3.divide(C, C, [2,2,2]);
  
  return [
    translate(A, sphere({radius:2}))
    ,
    translate(B, sphere({radius:2}))
    ,
    translate(C, sphere({radius:1}))
  ];
}
 
module.exports = { main } 
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1677666846588-capture-d-%C3%A9cran-du-2023-03-01-11-33-03-resized.png" alt="Capture d’écran du 2023-03-01 11-33-03.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://openjscad.nodebb.com/post/1309</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/1309</guid><dc:creator><![CDATA[gilboonet]]></dc:creator><pubDate>Wed, 01 Mar 2023 10:34:09 GMT</pubDate></item></channel></rss>