public Vector2 interp(float t)
{
Vector2 a = Vector2.Lerp(Vector2.zero, p1, t);
Vector2 b = Vector2.Lerp(p1, p2, t);
Vector2 c = Vector2.Lerp(p2, Vector2.one, t);
Vector2 d = Vector2.Lerp(a, b, t);
Vector2 e = Vector2.Lerp(b, c, t);
return Vector2.Lerp(d, e, t);
}
public override double calcVolumeFactor() { double volume = 0; var pp = new Vector2(radialFactor, 0); var slope = new BezierSlope(coneShape); for (int i = 1; i <= heightSegments; ++i) { float v = (float)i / heightSegments; Vector2 p; if (radialFactor <= topFactor) { p = slope.interp(v); p.x = Mathf.Lerp(radialFactor, topFactor, p.x); } else { p = slope.interp(1 - v); p.y = 1 - p.y; p.x = Mathf.Lerp(topFactor, radialFactor, p.x); } double r = (p.x + pp.x) * 0.5; volume += r * r * (p.y - pp.y); pp = p; } return volume * stretchFactor * volMultiplier * utilization / 0.8692f; }