Announcement

Collapse
No announcement yet.

Get the highest slope along a spline

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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

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

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

    #2
    Step by step video for finding the angle between two 3D vectors written out: https://www.youtube.com/watch?v=QWIZXRjMspI 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)?
    Last edited by Ed.Kaminski; 05-23-2020, 08:17 PM.

    Comment


      #3
      Originally posted by Ed.Kaminski View Post
      Step by step video for finding the angle between two 3D vectors written out: https://www.youtube.com/watch?v=QWIZXRjMspI
      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.

      Comment


        #4
        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.
        Last edited by Ed.Kaminski; 05-23-2020, 08:31 PM.

        Comment


          #5
          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.

          Comment


            #6
            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
            Code:
            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.
            NodePrefabs | PluginBuilder | NotificationBackbone | WidgetBox | RuntimeMeshImportExport | DebugWidget | SteamWorkshopAccessor

            Comment

            Working...
            X