Bing/ChatGPT4 wrote code today ... im/de/pressive !
-
I drank the Kool-Aid: it tasted like the refrigerated air in gigantic server farms with top-notes of ozone and mass-layoff sweat.
Quote:
To determine if a circle is in an ellipse in C#, you can use the following code: public bool IsCircleInEllipse(RectangleF ellipseBounds, PointF circleCenter, float circleRadius) { var xRadius = ellipseBounds.Width / 2; var yRadius = ellipseBounds.Height / 2; var xCenter = ellipseBounds.X + xRadius; var yCenter = ellipseBounds.Y + yRadius; var dx = Math.Abs(circleCenter.X - xCenter); var dy = Math.Abs(circleCenter.Y - yCenter); if (dx > xRadius || dy > yRadius) return false; if (dx <= xRadius - circleRadius && dy <= yRadius - circleRadius) return true; var xCornerDist = dx - xRadius; var yCornerDist = dy - yRadius; var cornerDistSq = xCornerDist * xCornerDist + yCornerDist * yCornerDist; return cornerDistSq <= circleRadius * circleRadius; } This code checks if the circle is completely inside the ellipse. If you want to check if the circle is partially inside the ellipse, you can modify the code accordingly. I hope this helps! Let me know if you have any other questions. Source: Conversation with Bing, 6/19/2023
p.s. none of the "relevant" links to published code examples included in the response were to articles with a solution to determining if a circle was fully contained in an ellipse.
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
-
I drank the Kool-Aid: it tasted like the refrigerated air in gigantic server farms with top-notes of ozone and mass-layoff sweat.
Quote:
To determine if a circle is in an ellipse in C#, you can use the following code: public bool IsCircleInEllipse(RectangleF ellipseBounds, PointF circleCenter, float circleRadius) { var xRadius = ellipseBounds.Width / 2; var yRadius = ellipseBounds.Height / 2; var xCenter = ellipseBounds.X + xRadius; var yCenter = ellipseBounds.Y + yRadius; var dx = Math.Abs(circleCenter.X - xCenter); var dy = Math.Abs(circleCenter.Y - yCenter); if (dx > xRadius || dy > yRadius) return false; if (dx <= xRadius - circleRadius && dy <= yRadius - circleRadius) return true; var xCornerDist = dx - xRadius; var yCornerDist = dy - yRadius; var cornerDistSq = xCornerDist * xCornerDist + yCornerDist * yCornerDist; return cornerDistSq <= circleRadius * circleRadius; } This code checks if the circle is completely inside the ellipse. If you want to check if the circle is partially inside the ellipse, you can modify the code accordingly. I hope this helps! Let me know if you have any other questions. Source: Conversation with Bing, 6/19/2023
p.s. none of the "relevant" links to published code examples included in the response were to articles with a solution to determining if a circle was fully contained in an ellipse.
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
I give that code a C-. Multiple return points, the two if statements should really have braces and composed as if-else-else with a "ret" variable so there's only one exit to the function, at the end! And a return with a conditional and computation in it just sucks, as it makes it more difficult to debug. Otherwise, the variable naming is good, and I wonder where it stole the code from. :laugh: And your p.s. is quite amusing, so much for the AI accurately referencing its sources.
Latest Articles:
A Lightweight Thread Safe In-Memory Keyed Generic Cache Collection Service A Dynamic Where Implementation for Entity Framework -
I give that code a C-. Multiple return points, the two if statements should really have braces and composed as if-else-else with a "ret" variable so there's only one exit to the function, at the end! And a return with a conditional and computation in it just sucks, as it makes it more difficult to debug. Otherwise, the variable naming is good, and I wonder where it stole the code from. :laugh: And your p.s. is quite amusing, so much for the AI accurately referencing its sources.
Latest Articles:
A Lightweight Thread Safe In-Memory Keyed Generic Cache Collection Service A Dynamic Where Implementation for Entity FrameworkIt also assumes one knows how to get the "bounding rectangle" for an ellipse in the first place. Yeah ... I also think the code is "lifted".
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
-
I give that code a C-. Multiple return points, the two if statements should really have braces and composed as if-else-else with a "ret" variable so there's only one exit to the function, at the end! And a return with a conditional and computation in it just sucks, as it makes it more difficult to debug. Otherwise, the variable naming is good, and I wonder where it stole the code from. :laugh: And your p.s. is quite amusing, so much for the AI accurately referencing its sources.
Latest Articles:
A Lightweight Thread Safe In-Memory Keyed Generic Cache Collection Service A Dynamic Where Implementation for Entity Framework@marc-clifton My sources at OpenAI and MS/Bing tell me that the effort to get generated code in C# optionally written in the flavor called "High Cliftonian" has been postponed again until at least spring 2024. cheers, bill
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch