Open stansu opened 5 years ago
Fast solution is to add rotation node for recipient. Nevertheless you found corner case that does not work properly. I think it relates with quaternions that used in this node. Perhaps if quaternions will be changed to matrix this gives correct result.
Unfortunately using of matrix does not give better result. Perhaps implementation of additional checkings can fix this situation.
mat_r = Matrix.Rotation(d_vector.angle(e_vector), 4, d_vector.cross(e_vector))
I'm reporting another wierd result that I'm getting from that node generating a path along a spiral:
It is mostly correct, but at some point it just twist. This is what happend if I multiply a circle along itself:
One of them is rotated of 90°.
Really nice Node anyway!
@alessandro-zomparelli Try to use duplicate objects along edges node. It has several different algorithms of determination position of new mesh. Also it is possible to create sinusoid along spiral without special nodes.)))
https://gist.github.com/Durman/df9a4bffb74cd513125d9f8d5f2cc862.js
Thanks @Durman It is exactely what I wanted. To be honest I loved adaptive edges for simplicity (I'm using Sverchock for some workshop and I really wanted to keep things simple). This approach gives the expected result but it's a bit too complicated to teach... :-( Apparently, if I got it correctly, in order to control the twist of object along a polyline/curve there are two strategies, specify an UP direction (like you did), or evaluating the curvature of the polyline in order to align coherently with that. Seems that Blender itself doesn't handle that correctly (while it do for Z up).
I tried to check the curvature graph in of a spiral in Rhino and I get a correct tilt of a curve in 3D space. (of course it's a NURBS, it should be more simple in that case)
I created a script for evaluating the normals/curvature and tangent vectors to a curve, maybe can help fixing some issues with "Adaptive Edges":
"""
in verts v d=[] n=[]
out nor v
out tan v
"""
from mathutils import Vector
curve_2D = False
plane_normal = Vector((0,0,1))
cyclic = False
normalize = False
if verts:
if len(verts[0])>2:
if cyclic:
verts = [verts[0][-1]] + verts[0] + [verts[0][0]]
else:
verts = [verts[0][0]] + verts[0] + [verts[0][-1]]
nor = []
tan = []
for i in range(1,len(verts)-1):
p0 = Vector(verts[i-1])
p = Vector(verts[i])
p1 = Vector(verts[i+1])
v0 = (p-p0).normalized()
v1 = (p1-p0).normalized()
t = (v0+v1)/2
if curve_2D:
n = t.cross(plane_normal)
else:
n = (v1-v0)
if normalize: n.normalize()
nor.append(tuple(-n))
tan.append(tuple(t))
if not cyclic:
tan[0] = tan[1]
tan[-1] = tan[-2]
nor[0] = nor[1]
nor[-1] = nor[-2]
tan, nor = [tan], [nor]
These are some examples: 2D normal (for having consistency with the direction like an offset should be):
3D Spiral:
Generic 3D curve (curvature not normalized):
Tangents:
@alessandro-zomparelli I also tried to do something in this direction.))
@Durman so what did you consider than? Can someone handle adaptive edges fixings?
would the transformation matrix from tangent the same clean?
would the transformation matrix from tangent the same clean?
you should consider both tangent and curvature direction.
when i use Adaptive Edges to create saw disc, it will have error when i use circle with vertices 6,10,14,18,22.... see my attachment for detail saw_disc.zip