Temporary variables with names or not are not a problem.
But you can significantly optimize this inequality.
Your code:
If maxEdgeLength / (Math.Sqrt(h * (h - a) * (h - b) * (h - c)) / h) <= MaximumTriangleAspectRatio Then
Multiply both sides by the square root, excluding division (the inequality persists because the square root cannot return a negative number):
If maxEdgeLength <= (Math.Sqrt(h * (h - a) * (h - b) * (h - c)) / h) * MaximumTriangleAspectRatio Then
Now a square on both sides to eliminate this expensive square root:
If maxEdgeLength * maxEdgeLength <= h * (h - a) * (h - b) * (h - c) / h / h * MaximumTriangleAspectRatio * MaximumTriangleAspectRatio Then
Cancel and multiply by h .
If maxEdgeLength * maxEdgeLength * h <= (h - a) * (h - b) * (h - c) * MaximumTriangleAspectRatio * MaximumTriangleAspectRatio Then
It will be much faster. If this calculation is repeated, consider caching the results of part of this expression for further improvement.
Use comments to explain the formula. How to get rid of the Math.Sqrt call in the bottleneck function is to write an expression in a less simple format.
Ben voigt
source share