Home Technical Talk

[GeoNodes] Find angle between verts or edges

Yerus
polycounter lvl 5
Offline / Send Message
Yerus polycounter lvl 5
0

I'm trying to figure out how to do it, I only neeed the angle from the X-Y axis between one segment and the next one. I checked out some other similar questions, but none of the ones I found were about curve segments. 

When I ask to chat GPT it gives me this formula, and I interpret it like that. The problem is the results don't seem accurate at all. But I feel that would be the way to go. The only thing in this example is that I haven't considered only the X-Y axis. 



    Replies

    • Thanez
      Offline / Send Message
      Thanez interpolator
      Hiya. IDK what's up with anything on your screen. Can't help you with the nodes as IDK what they do, I'm not familiar with Dot Product, so I don't quite understand what that formula is meant to say. I have however just made my own angle calculator that uses logic to skip multiple steps of Pythagoras et al to create/find vectors of lines to be used further. Because it's impossible for me to follow your logic, here's mine in the hope that it might help.
      If your geometry is a square box between 4 Vertices with XY coords:
      V1: 0,0
      V2: 500,0
      V3: 500,500
      V4: 0,500
      Then the Lines making up that box will go [from,to]:
      Line1: V1,V2
      Line2: V2,V3
      Line3: V3,V4
      Line4: V4,V1
      Skipping a few steps because I assume you're already here, ultimately they'll have Vector Angles of:
      Line1Vector: 0°
      Line2Vector: 90°
      Line3Vector: 180°
      Line4Vector: 270°
      What you're looking for is the DeltaVectorAngle of the Next and Previous Lines of any Vertex.
      Vertex 1: Line1Vector - Line4Vector. But for you, nothing, I guess?
      Vertex 2: Line2Vector - Line1Vector.
      Vertex 3: Line3Vector - Line2Vector.
      Vertex 4: Line4Vector - Line3Vector. Also nothing for you because spline?
      However, that'll create some issues of creating negative values. Let's clamp it back to 0°-360°:
      TempVertexAngle2: if (Line2VectorAngle - Line1VectorAngle < 0) {Line2VectorAngle - Line1VectorAngle + 360} else {Line2VectorAngle - Line1VectorAngle}
      Etc.
      You also seem to only want cutiepie angles, and that can be fixed by only accepting values lower than 180:
      VertexAngle2: if (TempVertexAngle2 > 180) {TempVertexAngle2 - 180} else {TempVertexAngle2}
      Etc.
      How to attach those values to the UI tho. And the cutie part of the geo, lol.

      IDK if that's useful, but it's what I got. Maybe it'll help you get to where you're going.
      Also don't expect any of that code to work, I was merely translating logic to something that might be more readable. This was translating the gibberish I have to something that you might be able to read :P

    • PolyHertz
      Offline / Send Message
      PolyHertz polycount lvl 666
      1. Get both vectors, and normalize them.
      2. Connect the normalized vectors to a dot product.
      3. Output the dot product to an arc cosine (NOT an arc sine!)
      I'm not sure offhand if the radian to degrees node is necessary, but otherwise that should be all you need.
    Sign In or Register to comment.