/// <summary> /// Funds the total surface area of a cylinder. /// </summary> /// <returns>The total surface area of the cylinder.</returns> /// <param name="D">The diameter of the cylinder.</param> /// <param name="h">The height of the cylinder.</param> /// <param name="circleCount">The amount of circles visible on the cylinder, by default this value is 2.</param> public float CylinderSA(float D, float h, CylinderCircleCount circleCount = CylinderCircleCount.two) { //finds radius from halving the diameter float r = D / 2; //2 * pi * r * h + circleCount(how many circles are visible on cylinder) * pi * r^2 return((2 * Mathf.PI * r * h) + ((float)circleCount * Mathf.PI * Mathf.Pow(r, 2))); }
public float CylinderSA(float D, float h, CylinderCircleCount circleCount = CylinderCircleCount.two) { float r = D / 2; if ((int)circleCount == 1) { return((2 * Mathf.PI * r * h) + (Mathf.PI * Mathf.Pow(r, 2))); } else { //2 * pi * r * h + 2 * pi * r^2 return((2 * Mathf.PI * r * h) + (2 * Mathf.PI * Mathf.Pow(r, 2))); } }