
Content count
541 
Donations
0.00 CAD 
Joined

Last visited

Days Won
25
Everything posted by konstantin magnus

Resample Curve by N attribute
konstantin magnus replied to philpappas's topic in General Houdini Questions
Hi philpappas, to extract main features of your curve you could first measure its curvature with the new measure SOP or by calculating the dot product of your tangents (see attachment). Afterwards a derivation of the curvature might be useful to only keep "break points" that are important to the visual appearance of your curve. I just would not know how to calculate this though. curve_curvature.hiplc 
Hi Niels, I tried the torus route as suggested on twitter: float r_torus = chf('radius_torus'); float r_tube = chf('radius_tube'); float freq = chf('frequency'); v@pos_rest = v@P; vector bbox = relbbox(0, v@P) * M_TWO_PI; v@P.x = (r_torus + r_tube * cos(bbox.x)) * cos(bbox.z); v@P.y = (r_torus + r_tube * cos(bbox.x)) * sin(bbox.z); v@P.z = r_tube * sin(bbox.x); v@Cd = noise(v@P * vector(freq)); v@P = v@pos_rest; seamless_noise.hip

(Animated) dashed line?
konstantin magnus replied to that Abstract guy's topic in General Houdini Questions
Yes, you could take the convertline SOP, promote the wave attribute to primitives and delete by this attribute. @DévinOdforce: I attached an example. dashed_curves_prims.hiplc 
(Animated) dashed line?
konstantin magnus replied to that Abstract guy's topic in General Houdini Questions
Let a sine wave run across your curves, set the dash length with frequency, animate by adding time and define the gap size by comparing the value with a custom threshold. float u = vertexprimindex(0, @vtxnum) / float(primvertexcount(0, @primnum)); float u_length = u * primintrinsic(0, 'measuredperimeter', @primnum); float u_anim = (u_length + @Time * chf('speed')); int waves = sin(u_anim * M_PI * chf('frequency')) < chf('gaps'); v@Cd = hsvtorgb( set(u, 1.0, 1.0) ) * waves; If you want your dashed line to be static just replace u_anim inside the sin() function by u_length. dashed_curves.hiplc 
A good way for making grid divisions depend on pixel resolution
konstantin magnus replied to Jaanus's topic in General Houdini Questions
On a gridnode just rightclick in order to switch the expression language to Python and use this: 2 replies

 2

 resolution
 cops to sops

(and 2 more)
Tagged with:

Orient noise pattern along vectors
konstantin magnus replied to konstantin magnus's topic in Scripting
Great idea @f1480187, creating the rotation matrices from the cage lines is definitely cleaner! 
I aligned vector directions towards some curves (ie. outer edges). How would I orient a stretched noise pattern accordingly? oriented_noise.hiplc

Orient noise pattern along vectors
konstantin magnus replied to konstantin magnus's topic in Scripting
Thanks for your help @tmdag. I had to invert the rotation matrix. So its: vector freq = chv('frequency'); vector dir = normalize( minpos(1, v@P)  v@P ); vector rect = normalize( cross(v@N, dir) ); vector nml = normalize( cross(dir, rect) ); matrix3 rot = set(dir, nml, rect); float deform = noise(v@P * invert(rot) * freq); v@P += v@N * deform * 0.05; 
Orient noise pattern along vectors
konstantin magnus replied to konstantin magnus's topic in Scripting
I have made some progress in making the wrinkles run towards the outer edges. Unfortunately i still get lots of warping issues that I can't quite explain. Ideally I want all folds to run in a parallel manner towards their nearest outer edge. This is the code I am currently using: vector pos_b = minpos(1, v@P); vector dir = normalize(pos_b  v@P); vector rect = cross(v@N, dir); vector nml = cross(dir, rect); matrix3 rot = set(dir, nml, rect); vector freq = {8, 1, 40}; vector pos = rot * v@P * freq; float deform = noise(pos); v@P += v@N * deform * 0.05; folds_wrinkles_2.hiplc 
Hi, I was shaping a hex nut with VEX when two geometry questions arose: How can I mathematically define the offset from a circle to an ngon? Currently I am multiplying by a magic number: sin(u_mod) * 0.12. How can I multiply vectors so they end up on an infinite plane defined by a position and a normal? Kind of what planepointdistance() does, but rather intersecting the plane with the points vector than just returning the closest position on the plane. Also I would not want to shoot rays around but rather set this mathematically. Here is how I deform the tubes outer points at the moment: float u = atan(v@P.z, v@P.x); float u_mod = abs(sin(u * 3)); float u_fit = fit01(u_mod, 0.75, 1.0); vector nml_flat = normalize(v@N * {1, 0, 1}); v@P = nml_flat * sin(u_mod) * 0.12; v@P.y *= u_fit; Thank you! hex_nut.hiplc

Multiply vectors to a plane (Trigonometry questions)
konstantin magnus replied to konstantin magnus's topic in Scripting
One question remains: How would one scale radial vectors so a circle turns into an ngon? 
Multiply vectors to a plane (Trigonometry questions)
konstantin magnus replied to konstantin magnus's topic in Scripting
Well, there wouldnt been a single line without your brain ; ) 
Multiply vectors to a plane (Trigonometry questions)
konstantin magnus replied to konstantin magnus's topic in Scripting
Thank you! And yes, by 'multiplying vectors' I was thinking of extending or shortening them, not thinking of using cross products here. So this is a visual summary in 5 steps: When we want to project the grey points from the inner circle on the plane of the outer points and their normals (turqoise), we aim in the opposite direction facing away from the plane points by subtracting circle point positions from the plane positions (yellow), create rectangular vectors to the plane normals by calculating a cross product of the aim direction and the plane points normals (red), and build the cross product of the planes normals and the rectangular directions while adding the planes position (green). When applying this result to the circle points positions, all points are projected on their targeted planes. int pt_plane = nearpoint(1, v@P); vector pos_plane = point(1, 'P', pt_plane); vector nml_plane = point(1, 'N', pt_plane); v@dir = v@P  pos_plane; // yellow v@rect = cross(v@dir, nml_plane); // red v@proj = cross(nml_plane, v@rect) + pos_plane; // green v@P = v@proj; project_on_plane.hiplc 
Multiply vectors to a plane (Trigonometry questions)
konstantin magnus replied to konstantin magnus's topic in Scripting
I exposed some parameters, in case someone is looking for a screw nut / cog wheel generator ; ) hex_nut.hiplc 
An even smoother result can also be reached by simply using the deltamush node. You can multiply the strength of this effect by this: vector delta = point(1, 'P', @ptnum)  v@P; v@P += delta * chf('strength'); surface_deltamush.hiplc

You could divide the distance to the borders by the maximum distance for each cell, modify this gradient to make it curved and use this to push the surfaces inwards. surface_inwards.hiplc

Thank you again! It performs nicely for exporting some sliced cityscapes that need 3d printing.

I want to export single tiles of a grid by their id attribute with Python. Because saveToFile() is lacking any filter options, I am trying to use a loop for deleting all redundant primitives before each export. Unfortunately once primitives have been deleted for the first time, they are gone for all subsequent loops, too. node = hou.pwd() geo = node.geometry() dir_exp = node.evalParm('dir_export') id_values = geo.primIntAttribValues("id") id_count = len(set(id_values)) # is there a more hou way to count unique attribute values? for iteration in range(id_count): geo_change = geo path_export = dir_exp + 'segment' + str(iteration) + '.obj' prims = [p for p in geo_change.prims() if p.attribValue('id') != iteration] geo_change.deletePrims(prims) # how can I keep the full geo data for the remaining loops? geo_change.saveToFile(path_export) How can I keep the full geometry for each loop? And are there any better ways to export geometry parts based on attributes with Python? landscape_slice_export.hiplc

[SOLVED] Animate points of polyline and keep distance?
konstantin magnus replied to that Abstract guy's topic in General Houdini Questions
Ok, then just get their initial position on the curve using xyzdist() and assign the updated position with primuv() like before. chain_move_2.hiplc 
[SOLVED] Animate points of polyline and keep distance?
konstantin magnus replied to that Abstract guy's topic in General Houdini Questions
It´s either irregular or it has to be rearranged. Just keep the resample node in there. 
[SOLVED] Animate points of polyline and keep distance?
konstantin magnus replied to that Abstract guy's topic in General Houdini Questions
Hi Devin, here is another way to make a chain move. chain_move.hiplc 
Dynamically create and remove nodes from Multiparm Block
konstantin magnus posted a topic in Scripting
How do I dynamically create and remove SOP nodes from a Multiparm Block List? dynamic_create_remove.hiplc 
I have created a tutorial on dart throwing a while ago: https://www.youtube.com/watch?v=Y1UC3T9l15U

[SOLVED] Animate points of polyline and keep distance?
konstantin magnus replied to that Abstract guy's topic in General Houdini Questions
https://www.sidefx.com/forum/topic/49994/ 
npointsgroup() returns the number of all points within a specific group. So if there are 5 points in a group, it will always return 5. Its not meant for iterating over points. int pts = npointsgroup(0, 'group1'); inpointgroup() however returns whether a certain point @ptnum is in a specific group or not (0 or 1). v@Cd = vector(0.0); if( inpointgroup(0, 'group1', @ptnum) != 0){ v@Cd.r = 1.0; } Or more compact: int in_grp = inpointgroup(0, 'group1', @ptnum); v@Cd = set( float(in_grp) , 0.0, 0.0);