3
$\begingroup$

I'm trying to create a geometry nodes system that one side of my instance always start on the position 0 and always ends on the world position 1 (even if it is rotated). To make this happen, I'm using a transformation node and trying to make the instance scales according the rotation. For this project, the rotation limits are between 0° and 45°. I managed to get the scale to work when the object is at 0° and also when it's at 45°, the problem is the values in between, like 22,5°. Any idea what node or function I could use to achieve this result? Thanks in advance for any help! an example

$\endgroup$

2 Answers 2

7
$\begingroup$

It's a little bit of trig.

The length of the rod, (with length L at 0 degrees,) is L/cos(theta)

enter image description here

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks a lot for the help! This helped me a lot and I will definitely use it more in future studies with Blender. $\endgroup$ Commented Oct 25, 2022 at 19:59
6
$\begingroup$

You can actually calculate the scaling based on a right triangle.

$b$ is at the beginning the one side with a scaling of $1$. If you change the angle, you would only have to calculate $c$, which is also your value for the scaling:

$c = \sqrt{b(tan^2(α) + b)}$

Translated into Geometry Nodes it should look like this:

enter image description here


(Blender 3.2+)

$\endgroup$
5
  • 1
    $\begingroup$ Crikey.. you've dug up one of the most obscure trig, identities ! I never learned that one.. :D $\endgroup$
    – Robin Betts
    Commented Oct 24, 2022 at 16:45
  • 1
    $\begingroup$ @RobinBetts Ahem, yes, I am not very proud of it ;-) ...but it works! In the end, I'm just more the type for weird thoughts, and you are the math pro :D $\endgroup$
    – quellenform
    Commented Oct 24, 2022 at 16:55
  • 1
    $\begingroup$ Nope.. no way pro. The only one i remember is SOHCAHTOA. Oh, and sin squared + cos squared = 1. The rest is trial and error :) $\endgroup$
    – Robin Betts
    Commented Oct 24, 2022 at 17:10
  • $\begingroup$ Thanks very much for the help! I knew that the solution could be related to a calculation based on a triangle, but I had no idea how to solve it, especially in blender 😁 I will start studyng more about trigonometric functions to learn how to solve this kind of problem too. Thank you! $\endgroup$ Commented Oct 25, 2022 at 19:57
  • 1
    $\begingroup$ @ThiagoVieira You're welcome! But to be honest, even if the answer works perfectly: The solution of RobinBetts is a tad better, due to the lower number of nodes ;-) $\endgroup$
    – quellenform
    Commented Oct 25, 2022 at 20:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .