simple task angle calculate

   12644   13   2
User Avatar
Member
32 posts
Joined: June 2008
Offline
Hello teachers
I have a very simple task that I can't solve; knowing that it is very easy
I'm trying to calculate the angle O in DEGREES according to the height h and radius r, like the drawing explains.
I tried both formulas but I can't make it right

90-(tan(ch(“../master_control/radiusbase”)/ch(“../master_control/height”)))
or
ch(“../master_control/radiusbase”)/(((ch(“../master_control/radiusbase”)*ch(“../master_control/radiusbase”)))+(ch(“../master_control/height”)*ch(“../master_control/height”)))/((ch(“../master_control/radiusbase”)*ch(“../master_control/radiusbase”)))+(ch(“../master_control/height”)*ch(“../master_control/height”))))

Help

Attachments:
anglecalculate.hipnc (84.1 KB)
anglecalculate.jpg (52.8 KB)

User Avatar
Member
32 posts
Joined: June 2008
Offline
the answer was simply:

((ch(“../master_control/height”)/ch(“../master_control/radiusbase”))*45) + 90

I hope this is right;;; ops:
User Avatar
Member
32 posts
Joined: June 2008
Offline
Hello again
I thought it was right
I'm attaching a file because it is easier to explain with.
on the right side in the green box are the guide lines that I want my shapes on the left blue box to follow, it works fine but then I got some multiplier values that I can't solve.
The idea is to get the I beams to follow the shape on the right side;;;
help please, I'm so bad in maths, but I did not believe that I'm that bad….Am I?

Attachments:
anglecalculate.hipnc (90.1 KB)

User Avatar
Member
639 posts
Joined: July 2005
Offline
hi,

it might actually be easier if you treat it as a vector instead, I think… So in any case, you can take the arc-cosine of the dot product of those 2 normalized vectors, that ought to easily give you the angle information.

I think the vangle() ought to give you exactly that. if you try:
vangle(vector r, vector (h-r)), where (h-r) is the hypotenuse of the line connecting the open end of h to r. This might be easier, perhaps?

example:
vangle(normalize(vector3( $TX, $TY, $TZ )), normalize(vector3( $TX2, $TY2, $TZ2 )))

HTH.
User Avatar
Member
32 posts
Joined: June 2008
Offline
Hello
Thank you for your reply, I'm a complete :?: head with vectors, normalize and everything related to.
Your way to caluclate the angle is much easier and cleaner to have; but in my example I can't put my hands on the components of the two points, I could guess the first one will be (0,h,0) and I can't guess the second point, even though i know it is the center of the object… no luck can't make it work.
Can anyone help me in that specific file, I know the theory but can't realise it via Houdini.
I know you guys are waiting for more challenging stuff//
User Avatar
Member
639 posts
Joined: July 2005
Offline
Hello,

I just checked out your hip file and made a little modification to it hopefully it'll make sense. Instead of relying on Align SOP to do the alignment for me, I simply use the point Normal to tell the Copy SOP how the alignment should be happening here. This “Normal” data, N, is simply a piece of data which the Copy SOP will look at to determine how a geometry should be oriented when copied to those points. Your geometry's Z-axis will line up with the direction of the point Normal. I've also added an Up Vector (“up” attribute. it's simply just {0,1,0} right now, but you'd have to do other vector math to get the up vector to be perpendicular to the normal). This will give your geometry a stable sense of orientation in order to eliminate sudden popping.

Anyways, your file is attached here. Hopefully it made sense. Let us know if you need help still.

Attachments:
anglecalculate_830_alex.hipnc (106.5 KB)

User Avatar
Member
32 posts
Joined: June 2008
Offline
Hey ALex
Thank you a lot, this really do the trick; and works perfectly, million thanx.
I still have two questions:
-Do u recommend any tutorials to help me understand better the up vector - normals calculations …. I'm really wanting to understand this as Houdini uses these mathematical tricks so often and this is a very field of interest that I lack most.
-in my model, I made a top SOP, to be able to increase the radius of the upper base, to let the Ibeams not to meet in the single zenith point, and to have further control in case I want them to expand instead of just intersecting up there.
I will try few things, but I'm sure I will go for another extereme non optimal solution.
Any help of that would be great.
Best best greetings from Paris
User Avatar
Member
32 posts
Joined: June 2008
Offline
i'm joining an example with a template to see what I mean.

Attachments:
anglecalculate_part2.hipnc (101.9 KB)

User Avatar
Member
32 posts
Joined: June 2008
Offline
I tried some tricks, but I think the upvector needs to be tweaked….
Ignore the previous message
regards

Attachments:
anglecalculate_part2.hipnc (106.2 KB)

User Avatar
Member
639 posts
Joined: July 2005
Offline
Hi there. In the point1 SOP, change the point(“../xform1”, 0, “P”, 0) to point(“../xform1”, $PT, “P”, 0) instead. What's happening here is that, instead of telling the point() to get the x position at point number 0, get the x position using the current point number instead. So if the current point number is 3, then $PT is 3, if currently point number is 10, $PT is 10, etc.

The Normal and Up Vector are just that – vector. It's a set of 3 numbers that either represent position or direction. Nothing more. Its importance is what those attributes mean. In Houdini's case here, it will recognize any vector attribute with the name “N” (Normal) or “up” (Up vector). Houdini will then take into account how N and/or “up” is to be used. Which in our case here, Houdini will use N to figure out how to orient a piece of geometry and that it uses “up” to figure out which way is supposedly pointing upward. When you think about it, if a point contain only a Normal, you know which direction the point is pointing, but you still don't know which way is supposedly upward. So when you introduce a second vector to that same point, which we'll call it “up vector” here, you are essentially creating a plane to here, and thus locking your orientation so that you now know which direction the point is pointing in addition to which way is considered upward.

The example inside the HIP file, what i simply did was to take point A and point B and subtract them to create a sense of line (which we'll treat it as a vector), and that was the Normal. That's basically about it. Of course, in a more complex situation, you might actually have to do more than just subtractions to get what you're after.

Hope that wasn't too confusing here..
User Avatar
Member
32 posts
Joined: June 2008
Offline
Hey Alex and thanx for the great introduction, I changed as you told, but it seems that the direction of normals is right, but doesn't match of the right direction of the skin1 is directed, I'm joining a small print to show you the result.
I hope I did not do any wrong manipulation.
Best regards

Attachments:
expression.jpg (50.9 KB)
wrong-normals.jpg (45.9 KB)

User Avatar
Member
639 posts
Joined: July 2005
Offline
Hi, you probably will have to change it for all 3 axis instead of just x-axis alone..
User Avatar
Member
32 posts
Joined: June 2008
Offline
I think I tried it out, but i wii give it a second shot..
thanx
User Avatar
Staff
2540 posts
Joined: July 2005
Offline
Nothing like learning to write shaders to master the math that is talked about above.

The Advanced RenderMan: Creating CGI for Motion Pictures has a nice chapter on the math required to write shaders. Covers trig, vectors, matrices and more. In the later chapters they cover shader writing in a great deal of detail.
In Houdini you can write shaders for geometry and cops which gives you instant feedback. You can also use VOPs to build up the shaders without resorting to writing code.


-jeff
There's at least one school like the old school!
  • Quick Links