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:
authorVladimir Spivak(cwolf3d) <cwolf3d@gmail.com>2020-12-21 01:58:30 +0300
committerVladimir Spivak(cwolf3d) <cwolf3d@gmail.com>2020-12-21 01:58:30 +0300
commit558edbcd1b3c7ad0370ec576dff7a5a4dfbcbcb8 (patch)
treee8a538e663c25e7d23ba9dd5c04757c186393e06 /mesh_looptools.py
parent3f35112dcfcabd002443a7475ae59499e09e4f1e (diff)
LoopTools: Added rotation of points aligned along a circle by a certain angle
Diffstat (limited to 'mesh_looptools.py')
-rw-r--r--mesh_looptools.py33
1 files changed, 26 insertions, 7 deletions
diff --git a/mesh_looptools.py b/mesh_looptools.py
index 55f08739..d13c4213 100644
--- a/mesh_looptools.py
+++ b/mesh_looptools.py
@@ -23,7 +23,7 @@
bl_info = {
"name": "LoopTools",
"author": "Bart Crouch, Vladimir Spivak (cwolf3d)",
- "version": (4, 7, 5),
+ "version": (4, 7, 6),
"blender": (2, 80, 0),
"location": "View3D > Sidebar > Edit Tab / Edit Mode Context Menu",
"warning": "",
@@ -2122,10 +2122,12 @@ def circle_influence_locs(locs_2d, new_locs_2d, influence):
# project 2d locations on circle, respecting distance relations between verts
-def circle_project_non_regular(locs_2d, x0, y0, r):
+def circle_project_non_regular(locs_2d, x0, y0, r, angle):
for i in range(len(locs_2d)):
x, y, j = locs_2d[i]
loc = mathutils.Vector([x - x0, y - y0])
+ mat_rot = mathutils.Matrix.Rotation(angle, 2, 'X')
+ loc.rotate(mat_rot)
loc.length = r
locs_2d[i] = [loc[0], loc[1], j]
@@ -2133,7 +2135,7 @@ def circle_project_non_regular(locs_2d, x0, y0, r):
# project 2d locations on circle, with equal distance between all vertices
-def circle_project_regular(locs_2d, x0, y0, r):
+def circle_project_regular(locs_2d, x0, y0, r, angle):
# find offset angle and circling direction
x, y, i = locs_2d[0]
loc = mathutils.Vector([x - x0, y - y0])
@@ -2151,8 +2153,8 @@ def circle_project_regular(locs_2d, x0, y0, r):
# distribute vertices along the circle
for i in range(len(locs_2d)):
t = offset_angle + ccw * (i / len(locs_2d) * 2 * math.pi)
- x = math.cos(t) * r
- y = math.sin(t) * r
+ x = math.cos(t + angle) * r
+ y = math.sin(t + angle) * r
locs_2d[i] = [x, y, locs_2d[i][2]]
return(locs_2d)
@@ -3495,6 +3497,14 @@ class Circle(Operator):
min=0.0,
soft_max=1000.0
)
+ angle: FloatProperty(
+ name="Angle",
+ description="Rotate a circle by an angle",
+ unit='ROTATION',
+ default=math.radians(0.0),
+ soft_min=math.radians(-360.0),
+ soft_max=math.radians(360.0)
+ )
regular: BoolProperty(
name="Regular",
description="Distribute vertices at constant distances along the circle",
@@ -3520,6 +3530,7 @@ class Circle(Operator):
row_right.active = self.custom_radius
row_right.prop(self, "radius", text="")
col.prop(self, "regular")
+ col.prop(self, "angle")
col.separator()
col_move = col.column(align=True)
@@ -3585,9 +3596,9 @@ class Circle(Operator):
r = self.radius / p.length
# calculate positions on circle
if self.regular:
- new_locs_2d = circle_project_regular(locs_2d[:], x0, y0, r)
+ new_locs_2d = circle_project_regular(locs_2d[:], x0, y0, r, self.angle)
else:
- new_locs_2d = circle_project_non_regular(locs_2d[:], x0, y0, r)
+ new_locs_2d = circle_project_non_regular(locs_2d[:], x0, y0, r, self.angle)
# take influence into account
locs_2d = circle_influence_locs(locs_2d, new_locs_2d,
self.influence)
@@ -4878,6 +4889,14 @@ class LoopToolsProps(PropertyGroup):
description="Distribute vertices at constant distances along the circle",
default=True
)
+ circle_angle: FloatProperty(
+ name="Angle",
+ description="Rotate a circle by an angle",
+ unit='ROTATION',
+ default=math.radians(0.0),
+ soft_min=math.radians(-360.0),
+ soft_max=math.radians(360.0)
+ )
# curve properties
curve_boundaries: BoolProperty(
name="Boundaries",