Curve From 2 Views

   2016   4   3
User Avatar
Member
3 posts
Joined:
Offline
I'm trying to make something similar to the Crv2View command in Rhino.

So I have this polygon curve:


And I want to move each point straight down in Y axis to line up with a NURBS curve, like so:


So I need to somehow find out what the Y position is on the NURBS curve at the appropriate X position. Basically I need to translate this pseudo-code into VEX:

foreach(Curve1.point) {
Curve1.point.yposition = getYposition(Curve2, Curve1.point.xposition);
}

Alas, I'm VEX-impaired so any help would be greatly appreciated.

Thanks.

Attachments:
top view rs.png (31.0 KB)
illustration rs.png (42.0 KB)

User Avatar
Member
1743 posts
Joined: March 2012
Offline
Try using a polygon curve, then if you really need a NURBS curve, you can use a Fit SOP with Method set to Interpolation to convert it to a NURBS curve going through those points after you have the points set up as you'd like them. The VEX code for setting the coordinates should be _much_ easier with a polygon curve than with a NURBS curve. Hopefully that approach works for what you need.
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
User Avatar
Member
670 posts
Joined: Sept. 2013
Offline
You could transfer the height of your side view curve to colors and flatten it.
@Cd = @P.y;
@P.y = 0;

Then let your top view curve shoot rays on the flattened side curve asking for the color to use it as its new height.
vector pos;
vector uv;
intersect(1, @P, {0,0,1}, pos, uv);
@P.y = primuv(1, "Cd", 0, uv);

Attachments:
curve_from_2_views.hipnc (94.0 KB)

https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
3 posts
Joined:
Offline
Konstantin Magnus
You could transfer the height of your side view curve to colors and flatten it.
@Cd = @P.y;
@P.y = 0;

Then let your top view curve shoot rays on the flattened side curve asking for the color to use it as its new height.
vector pos;
vector uv;
intersect(1, @P, {0,0,1}, pos, uv);
@P.y = primuv(1, "Cd", 0, uv);

Works like a charm. Big thanks to both of you. Much appreciated.

On a related note, I don't suppose there's a way to visualize the rays sent by intersect, sort like point trails?
User Avatar
Member
670 posts
Joined: Sept. 2013
Offline
jacksprophet
I don't suppose there's a way to visualize the rays sent by intersect, sort like point trails?

Sure, intersect() returns the hit position, as well. Subtracting pos and the current point position @P right after it should show you the rays, eg:

vector pos;
vector uv;
intersect(1, @P, {0,0,1}, pos, uv);
v@ray = pos - @P;
//@P.y = primuv(1, "Cd", 0, uv);

It kind of overshoots when you turn the visualization button on, though. Dont know why.
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
  • Quick Links