Wrap Curve To Cylinder, Pitch Blend Helices

Next
 From:  bemfarmer
8357.1 
After many hours of study and script writing, the _WrapCurveToCyl script worked very well.

Two Helices of different pitch may have their pitches G1 Blended. This will eliminate the kink in
the join of the two helices, and eliminates kink in a swept circle. Compression spring is an example.
After sweeping a circle, the spring can be Ctrl+C copied from the MoI screen, and in Geomagic Design, a Ctrl+V pastes the Pitch Blended Helix
into GD, where it looks very nice.
Limited Flow attempts were unsuccessful. Blending the two helices directly would work, if the Bulge could be made to pass through
a point on the surface of the Cylinder. Maybe this would be possible for an improved Blend using some NewtonRaphson?

_WrapCurveToCylinder by Brian McMillin March 26, 2017.

PARAMETER DESCRIPTION:
The Front View is convenient.
This script refers to an invisible Cylinder of radius "r", with axis along the positive Z-axis. (OR CENTERED AT -RADIUS)
The "Profile" of the Cylinder is the invisible circle of radius "r", at its base.
The source curve should be 2d, and be located in the XZ plane. (2d is not required.)
Quadrant I of the XZ plane is suggested, but not essential.
The source curve could have been set up or created with an xOffsetValue greater than zero,
with xOffset = xOffsetValue * 2 * radius, which would separate cylinder from XZ curve.)
xOffset is not used at this time.
These setups could be more general, but follow conventions of the reference paper.
At present, at leaset one point should be pre-created, say at the start of the source curve,
or it could be elsewhere.

SCRIPT DESCRIPTION:
Script description with xOffset = zero (otherwise x would be replaced with (x - xOffset)):
curves located in the XZ plane, are selected, and wrapped to the Cylinder.
So z values of points on the source curve equal z values of the curve wrapped on the cylinder.
The wrapping, or mapping, is accomplished by Arraying multiple points P along the source curve.
Each point P has coordinates = (x, 0, z). (The y value is ignored.)
Note that x values are measured in radians, and that x = arclength.
ArcLenths on the Profile circle will equal x Values of the source curve.
"Theta" refers to the angles of the Profile circle of the cylinder.
Note that for a circle, ArcLength = Theta * r, so Theta = (ArcLength / r) = (x/r).

WRAPPING EQUATION for points of the new curve wrapped on the cylinder, mapped from a source curve:
Given source curve point P = (x, 0, z), Cylinder coordinates of the wrapped curve point PCyl are:
PCyl = (xPrime, yPrime, z) = ((sign * r * sin(x/r)), (r * cos(x/r)), z).
(OR y COORDINATE COULD = -1 * (r*cos(x/r) -r) )
var sign is negative for a reverse wrapped curve.
An interpcurve factory is used to connect the PCyl points, to create the new wrapped curve.

The initial purpose of this script was to connect helices of different pitches by Blending,
to remove the kink where two helices of different pitch join. There could be 2+ helices to Blend.
The two+ helices should be "in phase," of the same twist, either left had or right hand.
So each helix has been unwrapped from the helix, to the XZ plane, where portions of the
helices adjoining the join point have been Trimmed away, and Blended and joined.
The resulting curve is then to be re-Wrapped to a helix with variable pitches.
This helix will be on the surface of an invisible cylinder. Zooming way in shows considerable accuracy.

(Unwrap curve, with move and rotate, was used to unwrap the helices, for testing purposes.)

The script _UnwrapCylCurve can be used to unwrap helices.
UNWRAPPING EQUATION for points of a new 2d curve, mapped from points of a curve on a cylinder:
Given point Pcyl = (xCyl, yCyl, z), where T = xCyl,
point P = ((r * arcsin(T/r)), 0, z). An interpcurve factory will be used.

Reference is the challenging to understand trigonometry and geometry paper of Apostol and Mnatsakanian:
http://mamikon.com/USArticles/RollingConesCylinders.pdf
The paper refers to Generalized Cylinders, which may be non-circular.
The Profile of a typical Cylinder is a perpendicular Circle in the xy plane.
The Profile of a Generalized Cylinder, gCyl, is a closed curve in the xy plane.
Given a formula for the Profile curve, UnWrapping of a curve on the gCyl,
or Wrapping of a 2d curve onto the gCyl, may be do-able.
QUESTION: Since a closed curve has a NURBS formula, could a person skilled in NURBS
do an Unwrap_gCyl script, and a Wrap_gCyl script?
(FLOW test to re-Wrap a Blended pair of unwrapped helices did not work for me.)
Later I may try to use calculated arclengths to do gCyl unwrapping and wrapping.




The Black curve is the source curve, to be selected for the wrap. The green start point is the second selection.
The script can work for closed curves, and other miscellaneous curves.
Wrapped helices are Left Hand or Right hand, depending upon quadrant and Reverse Twist checkbox.
There are probably some bugs left, but the script works well for the limited testing done.

- Brian

I have not yet written _UnwrapCylCurve script.

EDITED: 28 Mar by BEMFARMER


  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
8357.2 In reply to 8357.1 
For quadrant (I = one) unwrapped blended pre-helix-wrap curve, default wrap is a Left Handed helix beginning at (0, -r, 0).
So to match pre-unwrapped helix, Reverse Twist checkbox may be used,
and a rotation to match the actual start point of the initial helix may be needed.
Adding an initial selection of the start point of the initial helix could be added to the script, to determine needed matching rotation.

Missing semicolon located.
radius = 0, division by zero possibility does not seem to hurt(?)

- Brian

EDITED: 27 Mar by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Message 8357.3 deleted 28 Mar by BEMFARMER

Previous
Next
 From:  bemfarmer
8357.4 
I rediscovered the arclength of a circular segment of a circle, created by a chord!

arclength = radius * Theta = radius * 2 * arcsin((sqrt(dx*dx + dy*dy))/(2*radius))

This should be very useful.

The equation is here, with delta_x and delta_y substituting for the chord length, by pythagorus:

https://en.wikipedia.org/wiki/Circular_segment

- Brian

EDITED: 12 Apr by BEMFARMER

Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
8357.5 
The UnwrapCylCurve script is now working well, using the formula in the previous post, but with a few problems.

Corner points, i.e. angles, between two joined curves cause wiggles, even with high point count. 2000 points is less wiggly than 500 points.
(Tight bends would probably also have wiggles.)

Is there some way to identify corner points?
Separate seems to do it.
Using separate and getStartPoints and getEndPoints may be a work around, with each segment arrayed separately.

The cylinder axis must be parallel with the z_axis.
Only one curve, which can be joined, is done at a time.

- Brian
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
8357.6 
A curve on a cylinder may be unwrapped, or unwound, with the _UnwrapCylCurve script.
Documentation and description is contained in the script .js and in the .txt files.
Three test files are in the Test3dmFiles zip, including "un" FLOW of intersecting cylinder, which is very close to the unwrapped intersection.
- Brian

Script deleted 4/14/2017
It works well for certain curves, but needs more work for non-helical, doubling back direction curves...
I may post it again after some changes. (Only 3 downloads.)

EDITED: 14 Apr by BEMFARMER

Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
8357.7 In reply to 8357.5 
Hi Brian, aside from using separate another way to gather corner points would be to get the list of segments of the curve, that's available by calling the .getSubObjects() method on a curve. Then on a segment there are also getStartPt() and getEndPt() methods same as there is on the parent curve. So something like this:

var segs = crv.getSubObjects();
for ( var i = 0; i < segs.length; ++i )
{
var seg = segs.item(i);
var pt = seg.getStartPt();
}

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
8357.8 In reply to 8357.7 
Thank you Michael.
That code should work well.
- Brian
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
8357.9 In reply to 8357.7 
.

EDITED: 18 Apr by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  bemfarmer
8357.10 
Here is version 5 of UnwrapCylCurve, which works well, and required quite a bit more work.
Michaels angle script was used to calculate arclength, with better accuracy.
Processing each segment of a joined curve was done by using Michaels forum posted code.
Unwrapped segments have not been rejoined.
Unwrapped location depends upon curve start point. Incorporating bounding box center may improve this.
Comments are in the .js.
Test curves included joined helices of different pitch and handedness, as well as cylinder projected, circle and pentagon and small curve.

FLOW may be used to unwrap cylinder curves that are less than a single turn, using base profile circle and unwrap circle.
Such a Flow unwrap is slightly larger than an UnwrapCylCurve version, but the two unwrapped curves agree very well to a few decimal places and zoom_in's.

- Brian

The curve needs to be on the cylinder, a planar curve will probably yield no results...
A test ellipse in the top view, rotated in the front view, did yield a "boat hull cross section-like curve."
The script is a bit slow. It takes about 1 second per 100 numpoints, per segment.

EDITED: 21 Apr by BEMFARMER

Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All