Angle between two Spline Points - Confused on Output

So disclaimer: I never was any good at math, and had a very-poor teaching experience in the mathematics department. But I’m trying to get better. (So if anyone knows of any good resources for getting up to speed on game-relevant math, I’d be happy to know of it)

So I’m working on making the editor a lot more fluent and easier to use with some custom systems, and the one I’m currently working on using Blueprints is a Pipe Creator, you plop the thing down and drag spline nodes around and it automatically creates pieces, elbows, and angles things for you and follows the spline path.

Actual Problem:
Currently what I’m trying to do is get the angle between two spline points so I can determine what sort of elbow mesh to create, be it a 30/45/60/90. So I googled my way through it, and found this (

However, my results are confusing me.


The first one is equaling zero because 0 - 1 = -1 and there is no -1 index. Got that. But as I drag my point straight out the “angle” keeps increasing. If both Vectors are facing the same way (which they should be because the tangent’s are both the same) and 2 out of the 3 axis’s are completely the same. Shouldn’t the angle be 0? We’re a straight line after all.

I think youre doing it wrong. You need a third reference point on the spline for the angles to be calculated correctly. Right now you seem to be calculating the angle between the vectors of the origin to the points.
Isnt there a function that gets the tangent vector for a point on a spline? From there you can then do a dot product between the two tangents. And go on to do angles…

I’m not entirely sure what you mean. I can pull the tangent’s off of the points and plug those into the dot product, but that still only leaves me with 2 points and not 3 like you mentioned.

No, using tangents leaves you with the two vectors you need for the proper angle caclulation.

Ohh now I see what you mean. What you need to do to get a dot product between them is two choose one of two spline points as reference point, let’s call it P. Then make two vectors P+T1 and P+T2, where T1 and T2 are tangents at points. Normalize both of them and take dot product of normalized vectors.

…and this approach actually won’t work. Simple example is to points, both have tangents pointing in X direction and one point is placed directly above another. Spline will have a S shape form but dot product of earlier described vectors would be 1 as they point into the same direction.
What you actually need is to take a third point in between two spline points in question and get it’s orientation - get direction along the spline. And this is what you need to compare to the other two.

nononono… tangents are already normalized vectors. You only needed the third reference point if you couldnt have retrieved the tangent vectors in the first place.
The s-shape you need to solve by having your sample points taken at the correct intervals.

That would work too yeah, thats the method I suggested if you didnt have tangents available.

Well being that pipe doesn’t really “bend” in a curve , instead it’s a combination of straight pieces hooked into a series of 2 common angles of 45 and 90, with an occasional 30 or 60 degree (extremely odd/rare) am I perhaps going about this the wrong way, being that I’m attempting using a Spline? Perhaps I should consider just an array of editable vectors?

The goal is to create some easy systems with the same basic concepts for building pipes, stairs, walls, railing, and other sorts using the same idea of dropping the actor then dragging points throughout where it would take a turn.

Hello there! I’m wondering, is there an opportunity to make cable “deflection” effect in spline? Cable component itself crashes my mesh, so I need an alternative way. I have the chain mesh, and I need to make physical deflection on it, so when I laying it in the game it automatically gets right deflection. Has someone did smth similar? Thank you in advance.

I checked it, tangents aren’t normalized. But GetDirection (AtSplinePoint/AtDistanceAlongSpline) returns a normalized vector.