# Moving/translating a set of points on a spline.

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

## 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 on other sites
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 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 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;            }

1. 1
2. 2
3. 3
Rutin
22
4. 4
frob
17
5. 5

• 9
• 33
• 13
• 13
• 10
• ### Forum Statistics

• Total Topics
632580
• Total Posts
3007191

×