# LERP operations on Transforms

I’m wondering if there was a reason LERP functions (on transform “local” values) were not included in the Transform class?
Is extending the Transform class like below a bad idea for some reason? Am I missing some built in functionality that eliminates the need for this? (I read all about Transform class in the docs, but worry I just missed it)
The goal is simply to enhance clarity/readability and to reduce redundant code.

If not a bad idea, well, feel free to use it, and any suggestions on improving it are welcome.

Edit: as suggested by Eric, I have change the parameter names from “speed” to “t” (same name as Vectopr3.Lerp parameter)

Edit: As suggest by Bonfireboy, I am renaming the functions to “LerpTowards” make it clear that they are NOT as generalized as the Vector3 LERP.

``````public static class TransformOperations
{
public static void LerpTowardsRotation(this Transform transform,Quaternion final_rot,float t)
{
Quaternion current_rot=transform.localRotation;
Quaternion set_rot=Quaternion.Lerp(current_rot,final_rot,t);
transform.localRotation=set_rot;
}
public static void LerpTowardsPosition(this Transform transform,Vector3 final_pos,float t)
{
Vector3 current_pos=transform.localPosition;
Vector3 set_pos=Vector3.Lerp(current_pos,final_pos,t);
transform.localPosition=set_pos;
}
public static void LerpTowardsScale(this Transform transform,Vector3 final_scale,float t)
{
Vector3 current_scale=transform.localScale;
Vector3 set_scale=Vector3.Lerp(current_scale,final_scale,t);
transform.localScale=set_scale;
}
}
``````

usage:

``````rotationAxis.transform.localRotation= Quaternion.Lerp( rotationAxis.transform.localRotation,some_quaternion,0.5f);
``````  rotationAxis.transform.LerpTowardsRotation(some_quaternion,0.5f);