static public VFXExpression TorusVolume(VFXExpression majorRadius, VFXExpression minorRadius, VFXExpression scale = null) { //(pi * r * r) * (2 * pi * R) var volume = CircleArea(minorRadius) * CircleCircumference(majorRadius); if (scale != null) { scale = new VFXExpressionAbs(scale); volume = volume * scale.x * scale.y * scale.z; } return(volume); }
static public VFXExpression SphereVolume(VFXExpression radius, VFXExpression scale = null) { //(4 / 3) * pi * r * r * r var multiplier = VFXValue.Constant((4.0f / 3.0f) * Mathf.PI); var volume = (multiplier * radius * radius * radius); if (scale != null) { scale = new VFXExpressionAbs(scale); volume = volume * scale.x * scale.y * scale.z; } return(volume); }
static public VFXExpression CircleArea(VFXExpression radius, VFXExpression scale = null) { //pi * r * r var pi = VFXValue.Constant(Mathf.PI); var area = pi * radius * radius; if (scale != null) //Circle are inside z=0 plane { scale = new VFXExpressionAbs(scale); area = area * scale.x * scale.y; } return(area); }
static public VFXExpression ConeVolume(VFXExpression radius0, VFXExpression radius1, VFXExpression height, VFXExpression scale = null) { //pi/3 * (r0 * r0 + r0 * r1 + r1 * r1) * h var piOver3 = VFXValue.Constant(Mathf.PI / 3.0f); var r0r0 = (radius0 * radius0); var r0r1 = (radius0 * radius1); var r1r1 = (radius1 * radius1); var result = (r0r0 + r0r1 + r1r1); var volume = (piOver3 * result * height); if (scale != null) { scale = new VFXExpressionAbs(scale); volume = volume * scale.x * scale.y * scale.z; } return(volume); }