Get the highest slope along a spline

Hello.

I’m trying to implement conveyor lines that the player can construct during gameplay. I have a certain set of rules that the player must consider, when constructing the conveyor.
One of these rules are the maximum slope allowed at any given distance along the spline.

However, I’m not sure how to calculate this.

I’ve looked into formulars to calculate the angle between two vectors, but I can’t seem to wrap my head around the maths :slight_smile:

Hence this post. I appreciate all the help I can get :slight_smile:

If you need further information to understand the issue, please don’t hesitate to ask. I’ll do my best to answer :slight_smile:

Step by step video for finding the angle between two 3D vectors written out: How to Find the Angle Between Two 3D Vectors - YouTube Also, when you say “slope allowed at any given distance along the spline” what do you mean? I’m imagining that you have conveyor segments that you’re connecting together, and their pitches may be set tilting upward/downwards, correct? And you have rules to make sure they’re set reasonably (say, between 45 and -45 degrees or something)?

Already saw this one. My issue is that vector a is at (0, 0, 0) and vector b is at some other random location like (600, 0, 150). Using the fomular from the video is somewhat useless to me, because of the vector a at (0, 0, 0). This is where Í don’t understand the math :). Or rather, how do find a solution to my issue.

Ah, ok. You’re simply talking about finding the slope between two points in space. I think this is what you’re after then: http://quiz.uprm.edu/visual3d/manual…lope_line.html Rise over run. Rise is the difference between their Z values. Run will be finding the distance between the two points in the XY plane.

Or do you mean that your conveyor segments are represented as vectors (direction and magnitude), but they have completely different locations (0,0,0 and 600,0,150)? Their locations do not matter. You can still apply the formula to find the angle between them.

assuming that the in and out of the conveyer are horizontal, the biggest slope is in the middle of the spline.

Somewhat like this. dunno if the function names are 100% correct




FVector direction= Spline->GetDirectionAtDistanceAlongSpline(Spline->GetSplineLength()/2);
float slope = FMath::Abs(direction.Z / FMath::Sqrt(direction.X*direction.X + direction.Y * direction.Y)); // Abs cause the slope might go down and you want only positive values for your comparison.