Jump to content
  • Advertisement
Sign in to follow this  
Spa8nky

Moving/translating a set of points on a spline.

This topic is 2903 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

If I have a spline that is defined as follows:


private List<Vector3> controlPoints; // List of control points for the spline
private ushort[] indices;
private List<Vector3> interpolatedPoints; // List of interpolated points located on the spline



how should I translate those points should I want the spline to move?

Should I move all the points once each time the spline is moved:


public void Translate(Vector3 movementVector)
{
for (int i = 0; i < interpolatedPoints.Count; ++i)
{
interpolatedPoints += movementVector;

if (i < controlPoints.Count)
{
controlPoints += movementVector;
}
}
}



Or should I use a transformation matrix?

Which one would you be inclined to use, and why?

Share this post


Link to post
Share on other sites
Advertisement
If you only want to do a translation, then do it this way. There's no point in using a matrix (which will use many more operations), when a simpler way will work just as well.

Share this post


Link to post
Share on other sites
Indeed. I was also avoiding the transformation matrix as I would need to store a collection of transformed points if I were to go with this method.

This is because I will require the world space coordinates of each point for calculations and there would be no point transforming each point each time a specific point is required.

Unless someone has a better suggestion?

Share this post


Link to post
Share on other sites
It depends on how interpolatedPoints is related to the spline. Transforming both at once means that both a coupled tightly. I assume that interpolatedPoints are used for rendering, so that the graphical representation and the mathematical basis are coupled here!?

However, this part of the code
            for (int i = 0; i < interpolatedPoints.Count; ++i)
{
interpolatedPoints += movementVector;

if (i < controlPoints.Count)
{
controlPoints += movementVector;
}
}
seems me inefficient and error-prone. It is inefficient because there is a chance that the continous program flow will be disrupted unneccessarily, and there is the chance that too little controlPoints get updated (although some unshown constraints may prevent that). It seems me better to use
            for (int i = 0; i < interpolatedPoints.Count; ++i)
{
interpolatedPoints += movementVector;
}
for (int i = 0; i < controlPoints.Count; ++i)
{
controlPoints += movementVector;
}
instead.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!