If you do need to remove points, the fastest method is going to always be removing as much as possible in one call. When solving a problem, removing points or prims is usually one of the slowest, if not THE slowest operation you can do, and should be avoided if possible. This is a very Houdini specific tip, however it’s something I run into enough that I felt it worth commenting on. But regardless, it was one of those simple solves that made me feel like I was a dank mathematician when in reality im just a scared child. I just want to point out that I am not the only person to solve this problem in this way, in fact it’s an ultra common solution. z )) int order = argsort ( atan_test ) pts = reorder ( pts, order ) addprim ( 0, "poly", pts ) Int pts = AN_ARRAY_OF_YOUR_POINTS vector pos foreach ( int pt pts ) append ( pos, vector ( point ( 0, "P", pt ))) vector cent = avg ( pos ) float atan_test //assuming it's 2d on the XZ axisįoreach ( vector p pos ) append ( atan_test, atan2 ( p. The angles returned by the arc-tangent then gives us the basis for which we can order our points as the angles are both unique, and for lack of a better word, wound about the point set’s center. Since our point set is not gaurenteed to be centered at the origin, we want to subtract off the average of our point set from our positions as a method of centering our point set. In our case we’re going to use the atan2() operator, which instead of taking in a slope, takes in the rise and run of our line, basically our X and our Y if we’re centered at the origin. Why does this work? If the trigonometric tangent operator returns the slope of a line given an input angle, then the arc-tangent operator returns an angle, given the slope of a line. And after sorting, the resulting polygon will be overlap free and totally coherent. We then want to sort our points based on these arc tangent values. From there we want to find the arc-tangent angle from each point position to the average position. The easiest (and as I later learned most popular) method is to first find the average position of all the points in the set. I was recently tasked with this problem: Given a set of unordered points in the 2d plane (X,Z), find a method of building a coherent polygon (no overlaps) containing all points. out += a string a = chs ( "group_a" ) int in_a = inprimgroup ( 0, a, primnum ) select_border_diff ( a, primnum ) format() instead of % cuz that's the newer/sexier convention for string replacement. } \n """ #define our class suffixes classes = "abc" for class_name in classes : #create a new attribute with the class name and output #use. So any string we return that contains vex code will get executed by this parameter. Like any python expression you need to return your result. You’ll know it’s working because the text box will turn purple. IN ANY TYPE OF WRANGLE right click your VEXpression parm, drop down a keyframe and set the vexpression language to python. Take a second and let that sink in, python. So like any string parameter, you can use hscript or python. It’s easy to miss that the VEXpression section of a wrangle is actually just a parameter like any string parameter, just thiccer. This is honestly like stuff you should only whip out when trying to impress a honey u kno? This is all pretty poorly written, so please don’t bully me :(ĪLL EXAMPLES IN THIS ARTICLE ARE AVAILABLE FOR DOWNLOAD ON MY GITHUB
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |