I am able to scale an object using a scaling function I wrote. Internally it builds matrices that are multiplied by each of the vertices to transform them. The parameters I give the scaling function tell it how much to scale the object by as a factor of its current scale.
I want my object's scale to smoothly oscillate between two values, so I have used Sin waves to build my scaling factor, which is:
1 + amplitude * (Mathf.Sin(2 * Mathf.PI * frequency* Time.time) - Mathf.Sin(2 * Mathf.PI * frequency * (Time.time - Time.deltaTime)))
The result looks very close to what I want, but with each oscillation, the object gets slightly smaller than before.
The problem is that my function is written so that it scales the vertices as a factor of its 'current' scale, which is always changing.