Curve to two lines

   5933   6   1
User Avatar
Member
217 posts
Joined: March 2006
Offline
Hi all,
is there any way to copy a curve or a part of a circle to the ends of two lines. See attached picture.

My first point(0) of my circle shall snap to point 1 of line1 and point(n) to point(0) of line2. The lines exists only in XY, XZ or YZ and the circle should lie in the same plane. So the BB of my two lines tells me about their orientation.

Any Idea

Detlef

Attachments:
CircleLine.jpg (5.4 KB)

User Avatar
Member
941 posts
Joined: July 2005
Offline
I think it's just a linear transformation – from a space with an x-axis of C-C to a space with an x-axis of L2-L1 (non-normalized since you're fitting to relative scales). And you can arbitrarily choose the y-axis of each system to be {-y,x}.
Here's a quick VopSop test which seems to do it:

//————————————————————————–
// Input 0: Circle
// Input 1: Line 1
// Input 2: Line 2
// Parameter pt0: the point number from line 1
// Parameter pt1: the point number from line 2
// Parameter yscale: optional scaling along the perpendicular of the fit
//————————————————————————–
vector $sp0,$sp1,$tp0,$tp1; // source and target points
if(import(“P”,$tp0,1,$pt0) && import(“P”,$tp1,2,$pt1) &&
import(“P”,$sp0,0,0) && import(“P”,$sp1,0,Npt-1))
{
vector $Xs = $sp1-$sp0; // source x-axis
vector $Xt = $tp1-$tp0; // target x-axis

// Source space
matrix $Ms = invert(matrix(set(
$Xs.x , $Xs.y , 0 , 0 ,
-$Xs.y , $Xs.x , 0 , 0 , // choose y-axis = {-X.y,X.x}
0 , 0 , 1 , 0 ,
$sp0.x , $sp0.y , 0 , 1
)));

// Target space
matrix $Mt = set(
$Xt.x , $Xt.y , 0 , 0 ,
-$Xt.y , $Xt.x , 0 , 0 , // choose y-axis = {-X.y,X.x}
0 , 0 , 1 , 0 ,
$tp0.x , $tp0.y , 0 , 1
);
// Transform
$newP = P * $Ms * set(1,$yscale,1) * $Mt;
}

P.S: That little sketch only operates on the XY plane. Just add a switch and move the matrix entries around for the other two planes – the principle is the same. Heck, you could make it fully 3D if you require that the inputs also have an Up vector…

Attachments:
circleline.hip (59.3 KB)

Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
User Avatar
Member
217 posts
Joined: March 2006
Offline
Thanks a lot,
matrix - yes there was something I've heard about ;o)
I can't get your idea to work in XZ. Maybe there is another solution for my problem.

1. I have a python script that builds a structure of points
2. I want to copy a geometry on each point that faces to the next point. But I have really strange problems with the direction. I've tried with LookAts, Parenting and UnParenting, copying of worldTransforms in all possible combinations in Python. I have to say that I'm not a one that is familiar with matrix math.

Because inside my bend.otl I start with a simple curve, my thought was to first copy just the curve to my point construction.

Thanks a lot, I will work further with your Idea…

Attachments:
Pipe2.jpg (9.6 KB)
Pipe1.jpg (6.3 KB)

User Avatar
Member
1145 posts
Joined: July 2005
Offline
I really have no idea what I'm talking about, but this looks similar to creating bones, where bones always point down their Z axis. If you could approach it that way then you'd have a predictable direction that doesn't rely on the space you are in.

For that matter, why not use the bone object, replacing bones with your pipe geometry? You'd have “pipe” (bone) length control already, for example.
The main custom part would be providing a library of pipe sections, with maybe check boxes to choose which piece to call in.
I guess the tricky part would be getting the flanges to mate.
“gravity is not a force, it is a boundary layer”
“everything is coincident”
“Love; the state of suspended anticipation.”
User Avatar
Member
217 posts
Joined: March 2006
Offline
Yes - that can be an idea. I have build an OTL for my flanges and I can change anything from soldering to pressed, bolted and screwed flanges. Size of any screw and all dimensions can be changed - BUT - ;o)

I want my own controls, so I can adjust f.e. from the 3 tube a new dimension, material an fitting type and T-Type tubes and so on, so I've tried to build my tool from 0. I havn't found the code (python) for bones to extract things I need to have a slight code…

So I trie it with bones… thanks for idea!

Detlef
User Avatar
Member
345 posts
Joined:
Offline
I'm not sure how precise you need to be but similar effect (bevelled corners) you can achieve by creating poly line, resampling it and converting to nurbs curve. The amount of resample drive the amount bevel on corners.

hope it helps
kuba
User Avatar
Member
941 posts
Joined: July 2005
Offline
Ah. I see. Always good to know what you actually want to achieve
Yeah, you're probably better off approaching this as an attribute-driven stamping thing – maybe do a pre-pass on the construction lines classifying each point by its number of neighbours (“valence”) and stuff it into an attribute (where maybe valence<2 =>“ no_joint”, valence==2=>“corner_joint”, valence==3=>“T-joint”, valence==4=>“X-joint”, etc), then stamp the appropriate rotated/scaled pieces according to the classification… something like that may work.

Anyway, just for the sake of completeness then, (not because I think this solves your problem), here's a version of the above which works on all planes (hit play to see it joining up in all directions).

//————————————————————————–
// Input 0: Circle
// Input 1: Line 1
// Input 2: Line 2
// Parameter pt0: the point number from line 1
// Parameter pt1: the point number from line 2
// Parameter yscale: optional scaling along the perpendicular of the fit
// REQUIRES: Lines 1 and 2 cannot be colinear.
// REQUIRES: Line2 must have at least two points.
// REQUIRES: Circle must have at least three non-colinear points.
//————————————————————————–
vector $sp0,$sp1,$sp2,$tp0,$tp1,$tp2; // source and target points
if(import(“P”,$tp0,1,$pt0) && // get source pts
import(“P”,$tp1,2,$pt1) &&
import(“P”,$tp2,2,$pt1^1) &&
import(“P”,$sp0,0,0) && // get target pts
import(“P”,$sp1,0,Npt-1) &&
import(“P”,$sp2,0,Npt/2) )
{
// Build the source frame (assumes sp0,sp1,sp3 are on the principal plane)
vector $Xs = $sp1-$sp0; // source x-axis
float $sl = length($Xs); // source scale
vector $Zs = $sl*normalize(cross($sp2-$sp0,$Xs)); // source z-axis
vector $Ys = $sl*normalize(cross($Zs,$Xs)); // source y-axis
// Build the target frame (assumes tp0,tp1,tp3 are on the principal plane)
vector $Xt = $tp1-$tp0; // target x-axis
float $tl = length($Xt); // target scale
vector $Zt = $tl*normalize(cross($tp2-$tp0,$Xt)); // target z-axis
vector $Yt = $tl*normalize(cross($Xt,$Zt)); // target y-axis

// Source space
matrix $Ms = invert(set(
$Xs.x , $Xs.y , $Xs.z , 0 ,
$Ys.x , $Ys.y , $Ys.z , 0 ,
$Zs.x , $Zs.y , $Zs.z , 0 ,
$sp0.x , $sp0.y , $sp0.z, 1
));

// Target space
matrix $Mt = set(
$Xt.x , $Xt.y , $Xt.z , 0 ,
$Yt.x , $Yt.y , $Yt.z , 0 ,
$Zt.x , $Zt.y , $Zt.z , 0 ,
$tp0.x , $tp0.y , $tp0.z, 1
);
// Transform
$newP = P * $Ms * set(1,$yscale,1) * $Mt;
}

Attachments:
circleline2.hip (86.7 KB)

Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
  • Quick Links