private void Update(EvaluationContext context) { var closeCircle = CloseCircle.GetValue(context); var circleOffset = closeCircle ? 1 : 0; var corners = Count.GetValue(context).Clamp(1, 10000); var pointCount = corners + circleOffset; var listCount = corners + 2 * circleOffset; // Separator if (_pointList.NumElements != listCount) { //_points = new T3.Core.DataTypes.Point[count]; _pointList.SetLength(listCount); } var axis = Axis.GetValue(context); var center = Center.GetValue(context); var offset = Offset.GetValue(context); var radius = Radius.GetValue(context); var radiusOffset = RadiusOffset.GetValue(context); var thickness = W.GetValue(context); var thicknessOffset = WOffset.GetValue(context); var angelInRads = StartAngel.GetValue(context) * MathUtils.ToRad + (float)Math.PI / 2; var deltaAngle = -Cycles.GetValue(context) * MathUtils.Pi2 / (pointCount - circleOffset); for (var index = 0; index < pointCount; index++) { var f = corners == 1 ? 1 : (float)index / pointCount; var length = MathUtils.Lerp(radius, radius + radiusOffset, f); var v = Vector3.UnitX * length; var rot = Quaternion.CreateFromAxisAngle(axis, angelInRads); var vInAxis = Vector3.Transform(v, rot) + Vector3.Lerp(center, center + offset, f); var p = new Point { Position = vInAxis, W = MathUtils.Lerp(thickness, thickness + thicknessOffset, f), Orientation = rot }; _pointList[index] = p; angelInRads += deltaAngle; } if (closeCircle) { _pointList[listCount - 1] = Point.Separator(); } ResultList.Value = _pointList; }
private void Update(EvaluationContext context) { var from = From.GetValue(context); var to = To.GetValue(context); var w = W.GetValue(context); var wOffset = WOffset.GetValue(context); var addSeparator = AddSeparator.GetValue(context); var rot = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), (float)Math.Atan2(from.X - to.X, from.Y - to.Y)); var array = addSeparator ? _pointListWithSeparator : _pointList; array.TypedElements[0].Position = from; array.TypedElements[0].W = w; array.TypedElements[0].Orientation = rot; array.TypedElements[1].Position = to; array.TypedElements[1].W = w + wOffset; array.TypedElements[1].Orientation = rot; ResultList.Value = array; }