- Home /
How to simplify the equation of a moving vertex if its object is squeezed?
I originally had this equation: startPoint + direction * t;
Where t is a range float that goes from 0 to 1. The idea was to get a point defined by t between a start point and an end point. However, then I discovered that these lines were curves... so the whole thing became more and more complicated:
void ShowCurveEquation()
{
float xVertex = originalVertex.x;//* 1
float xVertex_T = originalVertex.x * frameMultX;//both are originalVertex.x * (1 + frameMultX * t)
//1 is original scale. frameMultX is how much it changes to reach its end scale, in this case 1 since it goes from 1 to 2.
Vector3 movementX = transform.right * xVertex;
Vector3 movementX_T = transform.right * xVertex_T;//Get that relative to the object´s rotation.
Vector3 movementY = transform.up * originalVertex.y;//y axis doesn´t change.
//Now here is the problem. With Z is the same as X, but dividing to get the curve: WE ARE WRITING ONLY THE FIRST PART and, once we know for sure the value of t, we do the rest to get the full number:
float incompleteMove_Z = transform.forward * originalVertex.z; // / (1 + frameMultX * t)
float curveEquation = transform.position + movementX + movementY;
float curveEquation_T = movementX_T;
//final equation = curveEquation + curveEquation_T * t + incompleteMove_Z / (1 + frameMultX * t);
}
All of this is the movement of a vertex from its start position to its end. So basically I have an object that´s being squeezed, incresing its x scale and reducing ts z scale while keeping a constant area.
So I went from this: Vector3 + Vector3 t;
To this: Vector3 + Vector3 t + Vector3 / (1 + float * t);
It works; but because am doing a lot of dot products and other stuff with those equations, this becomes longer and longer and results in cubic, quatric and quintic equations sometimes (which involve a lot of hard calculations), so keeping this structure is not an option.
...My question is, is there a way of getting another equation with the same result, but skipping the division?
I know that (1 + frameMultX t) is the current scale on the x axis. And I know that 1 / (1 + frameMultX t) is the current scale on the z axis, because the scale area divided by the scale on one axis gives the scale on the other axis. But all of this leads to the same. I always end up dividing by a linear equation, which is what causes the problem.
I also tried applying the same principle on the other axis, which is 1 + frameMultZ itsRelativeT; itsRelativet is: (1 / (1 + frameMultX t) - 1) / frameMultZ; But as you can see, it has the same problem.
I was thinking of finding a way of getting this that doesn´t involve dividing the area by the opposite axis, but I can´t find a pattern. I know, for example, that if t = 0.5 , then the scale on x is 1.5 and z is 0.6666. Again, x goes from 1 to 2 and z from 1 to 0.5, so x has advanzed its half and z two thirds.
Thanks in advance.
Your answer
Follow this Question
Related Questions
Adjust scale of object based on distance to maintain same perceived size 2 Answers
Intersection Point Between 2 AnimationCurves 0 Answers
equation game question need help 1 Answer
How to you make a number squared in C#? 2 Answers
[Maths] How to project a curve in two axis? (Grav y + RelativeVelocity x) 4 Answers