mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-09 16:26:47 +02:00
refactor: use _face_normal
This commit is contained in:
@@ -8,13 +8,11 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
use <../__comm__/_face_normal.scad>;
|
||||||
use <../util/sum.scad>;
|
use <../util/sum.scad>;
|
||||||
use <sf_solidify.scad>;
|
use <sf_solidify.scad>;
|
||||||
|
|
||||||
module sf_thicken(points, thickness, direction = "BOTH", convexity = 1) {
|
module sf_thicken(points, thickness, direction = "BOTH", convexity = 1) {
|
||||||
function tri_normal(tri) =
|
|
||||||
let(v = cross(tri[2] - tri[0], tri[1] - tri[0])) v / norm(v);
|
|
||||||
|
|
||||||
function vertex_normal(sf, xi, yi) =
|
function vertex_normal(sf, xi, yi) =
|
||||||
let(
|
let(
|
||||||
xy = [xi, yi],
|
xy = [xi, yi],
|
||||||
@@ -35,7 +33,7 @@ module sf_thicken(points, thickness, direction = "BOTH", convexity = 1) {
|
|||||||
v2 = sf[vi2[1]][vi2[0]]
|
v2 = sf[vi2[1]][vi2[0]]
|
||||||
)
|
)
|
||||||
if(!(is_undef(v0) || is_undef(v1) || is_undef(v2)))
|
if(!(is_undef(v0) || is_undef(v1) || is_undef(v2)))
|
||||||
tri_normal([v0, v1, v2])
|
_face_normal([v0, v1, v2])
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
sum(normals) / len(normals);
|
sum(normals) / len(normals);
|
||||||
@@ -52,7 +50,7 @@ module sf_thicken(points, thickness, direction = "BOTH", convexity = 1) {
|
|||||||
|
|
||||||
midy = leng_points / 2;
|
midy = leng_points / 2;
|
||||||
midx = leng_point0 / 2;
|
midx = leng_point0 / 2;
|
||||||
nv = tri_normal([points[midy][midx], points[midy + 1][midx], points[midy][midx + 1]]);
|
nv = _face_normal([points[midy][midx], points[midy + 1][midx], points[midy][midx + 1]]);
|
||||||
|
|
||||||
if(nv * dir_v > 0) {
|
if(nv * dir_v > 0) {
|
||||||
sf_solidify(surface_another, points, convexity = convexity);
|
sf_solidify(surface_another, points, convexity = convexity);
|
||||||
|
Reference in New Issue
Block a user