Jump to content

slope of a curve


michael

Recommended Posts

I have a curve that I'm using as a path object and i'd like to get the slope of the curve where the object is along that path in order to drive some other parameters...

I haven't been able to find much in the docs on getting this info...anyone have any ideas?

thanks

Link to comment
Share on other sites

Add UVTexture SOP (Rows&Columns, Point texture)

Add AttribCreate SOP (name: slope, class: Point, type: Vector)

valuex: primduv("../"+opinput(".", 0), 0, "P", 0, $MAPU, $MAPV,1,0)

valuey: primduv("../"+opinput(".", 0), 0, "P", 1, $MAPU, $MAPV,1,0)

valuez: primduv("../"+opinput(".", 0), 0, "P", 2, $MAPU, $MAPV,1,0)

Link to comment
Share on other sites

Assuming you have the displacement vector (Not as in Displacement Shader) of the object at any point on the curve,

I guess slope would be y/(hypot(x,z)) (oops, Maya talk) OR y/sqrt(x^2+z^2)

Shuffle the components around depending on which axis you want the slope relative to

... I think :blink:

correct me if i'm wrong please

oh atan (y/sqrt(x^2+z^2) ) would give you the angle if thats what you want

Link to comment
Share on other sites

hmm...

well I tried th suggestions but while I'm getting results I :

a) don't know what to do with the values , and

B) the values don't seem to be changing with the position on the path of my obj.

am I thinking of something else when I talk of 'slope'? - from what remember of high school math - a slope of 0 is just flat on the XZ plane, where a slope of 1 would be perpendicular to that - straight up in Y. if I draw a random curve in the viewport in xzy, every point on that curve will have a different slope between 0-1....

Link to comment
Share on other sites

Slope in Math (2D) is defined as change in y/ change in x . Which is basically the first differential of y in x so on a p-t graph (thats position-time) slope would give you the velocity of your object at any given time. Same way the second differential would give you change in velocity/ change in time = acceleration.

both primduv and the slope chop are doing pretty much the same thing

the slope chop's pop-up help explains this pretty well so you can calculate

1st differential = velocity

2nd " = acceleration

3rd = change in accel

What exactly do you want to get and how do you want to use it. Maybe slope isn't what you really want

PS: Does'nt the slope chop give you a ( non-straight-line graph??, I'm getting one here )

Also note: A slope of 1 would be a vector angled at 45 deg from x, Not straight up in Y

Link to comment
Share on other sites

hmmm...there are two or three nurons firing here....they're old and not connected to anything :(

what I'm doing is:

I have a butterfly on a path

the wing flapping is being driven by a wave chop

I'd like to control the amplitude of the wave chop with the position of the butterfly on the path - so as the butterfly moves up in Y (path gets steeper) the amplitude increases, as it goes down the amplitude decreases, giving the effect of it's wings flapping more to gain altitude | less to loose altitude...

I thought it would be easy to find the values I need, though I didn't know how..., am I after the wrong thing?

...so the slope of a curve would reach infinity as it got steeper? - that seems vaguely familiar....

Link to comment
Share on other sites

geometry chop

target - butterfly

reference- null at origin

slope chop (set to acceleration) will give you accel in all three axes, you need y, so isolate it.

slope (1st derivative) of this y channel can be used as a multiplier for your wave.

might be worth a shot, will have to verify myself

Link to comment
Share on other sites

thanks...getting there :)

edit -

I think I have this worked out >

I'm using the object chop > delete to bring in and isolate the butterfly's TY, then using that to drive a multiply on the second wave chop....

but I think I can get what I want if I can use a slope chop right after the delete to drive the period of my original wave chop...

so....

1) is there a chop that will output the abs() of it's input

2) I've tried to hook up the export to the period param of the wave chop, but it's not doing anything - not giving me the orange channel. there's something goofy about the 'path' field in the export chop...it's a string but seems to not like ch() references....

have to keep plugging away on this, but it's getting really close

Link to comment
Share on other sites

Hey arctor,

1) is there a chop that will output the abs() of it's input

Math CHOP -> Channel Pre OP (Positive)

2) I've tried to hook up the export to the period param of the wave chop, but it's not doing anything - not giving me the orange channel. there's something goofy about the 'path' field in the export chop...it's a string but seems to not like ch() references....

have to keep plugging away on this, but it's getting really close

Use ch() in the parameter you want to reference the Wave CHOP's Period parameter instead of the Export CHOP. Also, the Path in the Export CHOP is the name of the parameter instead of the path to the OP. Therefore,

Channels -> *, Node -> /obj/geo1, Path -> ty

will export the channel to geo1's ty.

You can only export channel(s) from CHOPs & not parameters of the CHOPs.

I hope the above helps!

Cheers!

steven

Link to comment
Share on other sites

Here's a slight modification to the file i posted. At least it helps to better visualise the final wave, and tweaking the flaps is a lot easier when you have seperate waves as opposed to multiplying the periods. Besides, it also leaves room for animating the wave properties for some interesting possibilities.

I used the trigger there coz it picks out places in the input where the slope is rising which is what you want anyway.

butterfly.zip

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...