The new NodeBox forum is live! Everything from support.nodebox.net moved here: sign in with the same email to pick up your old posts. Something not working? Write to forum-support@nodebox.net.
having a rects width and height value, I would like to draw a rect that has the length and angle of the diagonal of that rect. To do this in trigonometry I would need a arctan function. But there is nothing like that in Nodebox 3 (I think). Is there another solution?
Thanks for help.
Philipp
LU
LUlucasnijs
Hello Philipp,
attached is a sample file. You can use distance and angle to do what you want, no need for atan. Another way would be to use some pythagoras calc to calculate the diagonal.
Lucas beat me to the punch, but since I made a demo network I'll share it anyway.
As Lucas said, the angle and distance nodes give you want you want. Both of these nodes need a start and end point. In this case you want those points to be opposite corners of your rectangle. So how do you get those points?
If you hook your rect to a point node you will get a list of the four corner positions of your rectangle. NodeBox rectangles start clockwise from the upper left, so you want a line from the fourth (last) corner to the second corner. For his solution Lucas first aligned the rect to the origin and started from the upper right so he could use 0,0 as his end point.
Just for fun I created an animation that shows how this works. I added a caption and some flourishes like a little angle arc. You can also use this example to see how easy it is to animate things in NodeBox.
Now I am thinking of a way to translate the rect so that it sits in the middle of the diagonal. But I didn't think to much about that yet. The big problem is solved.
Thank you very much again.
Philipp
LU
LUlucasnijs
You're welcome!
Use the centroid node, attach the first rectangle to it, use this point to translate your diagonal rectangle to and hopla! (be sure your rectangle is aligned properly before you translate)
JO
JOjohn
You are most welcome, Phillip. Thanks too, Lucas. It's fun to tag team with you.
Here, just for fun, is another demo: a set of recursive rectangles. Each child rectangle is centered and rotated along the major diagonal of its parent. You can individually scale each child. Changes to the original rectangle produce dramatic results!
Screenshot and network attached. Enjoy! And please consider sharing whatever you finally come up with in the Show Your Work forum.