<?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[Flattening 3d triangle]]></title><description><![CDATA[<p dir="auto">Hello, flattening 3d triangle is very useful for all kinds of projects, and it's not available at this moment on V2, so here's a little function that does it. It comes from this discussion : <a href="https://stackoverflow.com/a/8051489" rel="nofollow ugc">https://stackoverflow.com/a/8051489</a></p>
<pre><code>function d2ize(p){
var x0 = p[0][0], y0 = p[0][1], z0 = p[0][2],
    x1 = p[1][0], y1 = p[1][1], z1 = p[1][2],
    x2 = p[2][0], y2 = p[2][1], z2 = p[2][2]
    
var X0 = 0, Y0 = 0
var X1 = Math.sqrt((x1 - x0)*(x1 - x0) + (y1 - y0)*(y1 - y0) + (z1 - z0)*(z1 - z0)),
    Y1 = 0
var X2 = ((x1 - x0) * (x2 - x0) + (y1 - y0) * (y2 - y0) + (z1 - z0) * (z2 - z0)) / X1,
    Y2 = Math.sqrt((x2 - x0)*(x2 - x0) + (y2 - y0)*(y2 - y0) + (z2 - z0)*(z2 - z0) - X2*X2)
    
return &lsqb;&lsqb;X0, Y0], [X1, Y1], [X2, Y2&rsqb;&rsqb;

}
</code></pre>
]]></description><link>https://openjscad.nodebb.com/topic/137/flattening-3d-triangle</link><generator>RSS for Node</generator><lastBuildDate>Mon, 20 Apr 2026 22:26:23 GMT</lastBuildDate><atom:link href="https://openjscad.nodebb.com/topic/137.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 26 Jun 2020 06:33:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Flattening 3d triangle on Fri, 26 Jun 2020 09:50:47 GMT]]></title><description><![CDATA[<p dir="auto">Thank you. I only work with triangulated models for coding simplicity, even if later (for designs clarity) I usually remove walls between co-planar neighbours. I will certainly soon start to make V2 versions of my code, was only missing this, but for the moment I'm making a vanilla JS pattern editor.</p>
]]></description><link>https://openjscad.nodebb.com/post/262</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/262</guid><dc:creator><![CDATA[gilboonet]]></dc:creator><pubDate>Fri, 26 Jun 2020 09:50:47 GMT</pubDate></item><item><title><![CDATA[Reply to Flattening 3d triangle on Fri, 26 Jun 2020 07:53:40 GMT]]></title><description><![CDATA[<p dir="auto">Cool. But be careful as the boolean operations can create polygons with more than three (3) vertices. Also, some of the primitives create polygons with four (4) vertices.</p>
]]></description><link>https://openjscad.nodebb.com/post/261</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/261</guid><dc:creator><![CDATA[z3dev]]></dc:creator><pubDate>Fri, 26 Jun 2020 07:53:40 GMT</pubDate></item></channel></rss>