Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Leger <stephen@3dservices.ch>2017-08-03 16:59:40 +0300
committerStephen Leger <stephen@3dservices.ch>2017-08-14 02:16:24 +0300
commitfde9aa0a3fe223e7f2eb03010faf626bac925780 (patch)
tree3cf8c0355c6892187527844d93669d0428e1f7da /archipack/archipack_2d.py
parent6e469175870222d724be17c9f14590a07e1e7e45 (diff)
archipack: Fix issue with curved segments in walls/slab/floor
Diffstat (limited to 'archipack/archipack_2d.py')
-rw-r--r--archipack/archipack_2d.py39
1 files changed, 36 insertions, 3 deletions
diff --git a/archipack/archipack_2d.py b/archipack/archipack_2d.py
index fcd578da..4bf0d1f1 100644
--- a/archipack/archipack_2d.py
+++ b/archipack/archipack_2d.py
@@ -116,6 +116,7 @@ class Line(Projection):
else:
self.p = Vector((0, 0))
self.v = Vector((0, 0))
+ self.line = None
@property
def copy(self):
@@ -162,6 +163,10 @@ class Line(Projection):
return atan2(self.v.y, self.v.x)
@property
+ def a0(self):
+ return self.angle
+
+ @property
def angle_normal(self):
"""
2d angle of perpendicular
@@ -365,7 +370,7 @@ class Line(Projection):
if hasattr(last, "r"):
res, d, t = line.point_sur_segment(last.c)
c = (last.r * last.r) - (d * d)
- print("t:%s" % t)
+ # print("t:%s" % t)
if c <= 0:
# no intersection !
p0 = line.lerp(t)
@@ -455,8 +460,6 @@ class Arc(Circle):
"""
Represent a 2d Arc
TODO:
- Add some sugar here
- like being able to set p0 and p1 of line
make it possible to define an arc by start point end point and center
"""
def __init__(self, c, radius, a0, da):
@@ -473,6 +476,7 @@ class Arc(Circle):
stored internally as radians
"""
Circle.__init__(self, Vector(c).to_2d(), radius)
+ self.line = None
self.a0 = a0
self.da = da
@@ -575,6 +579,15 @@ class Arc(Circle):
"""
return self.r * abs(self.da)
+ @property
+ def oposite(self):
+ a0 = self.a0 + self.da
+ if a0 > pi:
+ a0 -= 2 * pi
+ if a0 < -pi:
+ a0 += 2 * pi
+ return Arc(self.c, self.r, a0, -self.da)
+
def normal(self, t=0):
"""
Perpendicular line starting at t
@@ -628,6 +641,26 @@ class Arc(Circle):
steps = max(1, round(abs(self.da) / step_angle, 0))
return 1.0 / steps, int(steps)
+ def as_lines(self, steps):
+ """
+ convert Arc to lines
+ """
+ res = []
+ p0 = self.lerp(0)
+ for step in range(steps):
+ p1 = self.lerp((step + 1) / steps)
+ s = Line(p0=p0, p1=p1)
+ res.append(s)
+ p0 = p1
+
+ if self.line is not None:
+ p0 = self.line.lerp(0)
+ for step in range(steps):
+ p1 = self.line.lerp((step + 1) / steps)
+ res[step].line = Line(p0=p0, p1=p1)
+ p0 = p1
+ return res
+
def offset(self, offset):
"""
Offset circle