magneto Posted September 9, 2012 Share Posted September 9, 2012 Hi, This is the opposite of what I asked last time. Basically I have 2 curves that are totally different by their length and number of points. What I am trying to do is to get the normalized UV coordinate of a point on Curve A, say point 3 is 0.271, and then get the corresponding point position in Curve B. In this case I would use primuv and feed it the UV coordinate I have which is 0.271. But I don't know how to get these normalized UV values for each point. I looked at the UV Texture SOP and used the Arclen Spline Length and other spline options and then normalized these values to 0-1, but the coordinates do not match, when I used Curve A for primuv. Can I calculate these UV values by measuring the length up to each point, dividing the result by the total curve length? I am not sure how to measure up to a point though since the arclen function requires UV coordinates. Anyhow is there a way to do this? Thanks Quote Link to comment Share on other sites More sharing options...
zarti Posted September 9, 2012 Share Posted September 9, 2012 to me it looks like you do not have good relationship with measure SOP .. just call it . =) Quote Link to comment Share on other sites More sharing options...
magneto Posted September 9, 2012 Author Share Posted September 9, 2012 Thanks zarti. I know about the Measure SOP but how can I use it to get the UV values of points? It would only give me the total length like arclen no? Quote Link to comment Share on other sites More sharing options...
zarti Posted September 9, 2012 Share Posted September 9, 2012 But I don't know how to get these normalized UV values for each point. { WoW ! nonCommercial version doesnt let me Paste code .. Haa ! another handjob for me } fit( $MAPU, 0, point( `opinputpath( '.',0 )`, $NPT-1, "uv", 0 ), 0, 1 ) -- here is a file which seems to work - with or without UVs ( Measure SOP assigns distance as attrib to each point ) .. - NURB / polys .. -- getProportionalLocation.hipnc -- .cheers 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted September 9, 2012 Author Share Posted September 9, 2012 (edited) Thanks zarti. You can copy using the NC version. Just open the external editor (Alt+E) So I looked at your file and found that you used the expression you posted in attribcreate1, which is connected to curve1. That was exactly what I was doing, but in this nodes until attribcreate1 there is no Measure SOP. I noticed you use it in other parts of the file. But the values calculated using my_distance doesn't give the correct values Try this expression: primuv("../attribcreate1", 0, "P", 0, point("../attribcreate1", 6, "my_distance", 0), 0) and you will see that returned value will not be the same as Point 6's X value. As for the Measure SOP, I noticed you were using Blast SOPs. Were you trying to delete everything but 1 segment and then measure its length? Because if you measure after deleting, the length of the segment changes. Thanks again Edited September 9, 2012 by magneto Quote Link to comment Share on other sites More sharing options...
jkunz07 Posted September 9, 2012 Share Posted September 9, 2012 Here's some methods I've used before Assign_U_Coordinates_to_a_Curve_ToPublic.hip 1 Quote Link to comment Share on other sites More sharing options...
zarti Posted September 9, 2012 Share Posted September 9, 2012 (edited) You can copy using the NC version. Just open the external editor (Alt+E) oh thanks , ill try to remember that . -- Measure SOP , which i mentioned in the first reply , was not part of the NURB's case . it was in the branch of polygon case and have used it before to measure segment lengths ( while in this one to measure ' how far ' is each point from point 0 ) . so , i could find the ratio to feed into Carve SOP or primuv expression ... but , But the values calculated using my_distance doesn't give the correct values Try this expression: primuv("../attribcreate1", 0, "P", 0, point("../attribcreate1", 6, "my_distance", 0), 0) and you will see that returned value will not be the same as Point 6's X value. .. but it should give exact values if segments are equal ( points distributed uniformly ) . so Carve and primuv exp. obey to something else but not 'physical lengths' . sad . and dont know Why that ( ??! ) edit: i tried to use a curve with all segments equal to each other and my method works . -- As for the Measure SOP, I noticed you were using Blast SOPs. Were you trying to delete everything but 1 segment and then measure its length? Because if you measure after deleting, the length of the segment changes. that Blast-ard escaped the cleanup i made of some nodes i was testing inside foreach . it is useless actually . -- so maybe a solution wd be to evenly resample curves ( in a parallel branch maybe ) to get the most accurate result possible without affecting original ones . Edited September 9, 2012 by zarti 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted September 9, 2012 Author Share Posted September 9, 2012 Thanks a lot guys. @John: I looked at your file, cool techniques but when I tried to feed the Red color values to primuv expression's u argument, it's still not exact to actual point positions. Were you able to see identical results on your tests? @zarti: I see what you mean. Uniform works for sure. But if the points are uniform, $PT/($NPT-1) would work too because the u coordinates would also be uniform. Are you sure Carve and primuv doesn't use the physical length? Since I don't know the exact U values of points, I can't verify 100%, but my tests show the U values you use for Carve and primuv seem to be precise by length. I think that's why finding the U coordinate is tricky 1 Quote Link to comment Share on other sites More sharing options...
zarti Posted September 9, 2012 Share Posted September 9, 2012 (edited) her is the proof Carve ignores physical length of curves ( primuv() should be the same ): - the segments are equal ( build with snapping to grid ON ) - set to display the nodes in black . the Carve is animated with linear() interpolation , while as you can see the speed is affected by points density . -- getProportionalLocation_proofOfNonLinearity.hipnc -- edit : if you create an UVTexture with texture type = Average Spline , it works here . put this in attributecreate2 node : $MAPU / point( opinputpath('.',0), $NPT-1, "uv", 0 ) but im guessing you already have UVs .. or not ?? edit2 : attachment added .. -- getProportionalLocation_workingWithAverageSpline.hipnc -- Edited September 9, 2012 by zarti Quote Link to comment Share on other sites More sharing options...
magneto Posted September 10, 2012 Author Share Posted September 10, 2012 Thanks zarti. Your idea works when the curve order is 2, when I increase it to 4, the values shift again I am not sure if Carve and primuv is supposed to be linear. Perhaps someone can shed a light? I have another idea to try so if it works, I will post it here. If it doesn't work, I will post it here Quote Link to comment Share on other sites More sharing options...
jkunz07 Posted September 10, 2012 Share Posted September 10, 2012 @John: I looked at your file, cool techniques but when I tried to feed the Red color values to primuv expression's u argument, it's still not exact to actual point positions. Were you able to see identical results on your tests? Attached file includes how I was planning to fetch point position based on normalized U value. I don't have any experience with the primuv expression, but in the file providing a U value between 0-1 returns an exact point position on the input curve. As far as the U coordinates being assigned to the curve, those are still an approximation. Assign_U_Coordinates_to_a_Curve_ToPublic_v002.hip 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted September 10, 2012 Author Share Posted September 10, 2012 Thanks John, very useful. I looked at the file again. How do you compare your generated U values to return the matching XYZ coordinates? Like which expression are you using? Quote Link to comment Share on other sites More sharing options...
jkunz07 Posted September 10, 2012 Share Posted September 10, 2012 Thanks John, very useful. I looked at the file again. How do you compare your generated U values to return the matching XYZ coordinates? Like which expression are you using? In the v002 file I just uploaded there's some added sops colored in like a mustard yellow. Using a point sop I'm shuffling P into Cd and $CR into $TX. $TY and $TZ are zeroed out. This creates a normalized line in the positive X direction. With the add sop I'm creating 1 point with a slider range 0-1 this slider sets $TX for the newly created point. Using a vopsop and pcfilter the nearest point's color is retrieved (which is actually the position). Kinda confusing, probably could be simplified, but it's what I came up with. 1 Quote Link to comment Share on other sites More sharing options...
petz Posted September 10, 2012 Share Posted September 10, 2012 (edited) i didn´t go throught the whole thread too carefully but can´t you just use "unituv" or $PT / ($NPT - 1) for that purpose? petz curve1.hipnc Edited September 10, 2012 by petz 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted September 10, 2012 Author Share Posted September 10, 2012 Thanks guys. @John: I will have to inspect your file more closely. I couldn't find time yesterday @petz: $PT / ($NPT - 1) only works for uniform points on a curve. If they are all over the values do not work. I looked at unituv from the docs but not sure how it works? I checked your file but the U values seem to be the same as $PT / ($NPT - 1). Quote Link to comment Share on other sites More sharing options...
stabby Posted September 13, 2012 Share Posted September 13, 2012 (edited) Hi, If you're working with polys, then you should convert your curves to nurbs, order 2. Use a basis SOP and change U parameterization to 'Approximate Arc Length'. The carve SOP and primuv etc. will use the new parameterization. EDIT: should probably add that changing the parameterization of nurbs with order > 2 will change the shape of your curve a little. Thanks guys. @John: I will have to inspect your file more closely. I couldn't find time yesterday @petz: $PT / ($NPT - 1) only works for uniform points on a curve. If they are all over the values do not work. I looked at unituv from the docs but not sure how it works? I checked your file but the U values seem to be the same as $PT / ($NPT - 1). Edited September 13, 2012 by stabby 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.