How to find optimum (least square error) “square splitting circular arc” with given two centroids?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I am looking for an analytic solution for the following problem. A unit square is given. Coordinates of two points inside the square are given. What is the best circular arc which splits the square in to two regions such that the given points are closest(least square error) to the centroids of regions?



Problem Explanation Figure



This problem came up due to the following scenario. Region 1 and Region 2 represents 2 fluids. The only information we know are the two centroids and their area density. I was previously splitting it with straight line but have only two degree of flexibility(slope and intercept) and my results were not satisfactory. So while moving to higher order I had options of quadratic and circular fit. I want to try circular fit because of its elegance and easiness to extrapolate to 3D as that is my final requirement.



My one of many attempts to tackle the problem was as following. I tried first to solve assuming there exists a circle as an exact solution for given inputs, Area, x and y (Area value is available)



a) consider two separate cases, arc cutting adjacent sides and diagonals.



b) connect ends of arc, find the centroid of circular segment and thus find equation for intersection area of circle and square.



c) Using area find equations for centroids.



d) solve 3 equations analytically(I could not see equations below) or numerically(I could do it in matlab)



But the draw backs are I cannot afford many iterations(millions of cells) and there are infinite cases when there is no solution for this cubic equation. In that case I need to differentiate the analytical term for error which I could not solve for even using software.



The 3 equations for one scenario was got like this (figure attached) this uses unknowns xo, yo and R for the equations with given inputs of area (A_Ch) and centroids (Cx_Ch and Cy_Ch)



gam = asin(y0/R);



del = acos(x0/R);



u = R*cos(gam)-x0;



v = R*sin(del)-y0;



s = -v/u



alpha = acos(x0/R)-asin(y0/R);
beta = acos(x0/R)+asin(y0/R);



A_Ch = 0.5 * ( R^2*alpha + 2*x0*y0 - y0*sqrt(R^2-y0^2) - x0*sqrt(R^2-x0^2) )



Cx_Ch = (2*R^3*(sin(alpha/2))^3 cos(beta/2)+0.5(sqrt(R^2-y0^2)-x0) * (sqrt(R^2-x0^2)-y0)*(2*x0+sqrt(R^2-y0^2)) )/(3*A_Ch) -x0



Cy_Ch = (2*R^3*(sin(alpha/2))^3 sin(beta/2)+0.5(sqrt(R^2-y0^2)-x0) * (sqrt(R^2-x0^2)-y0)*(2*y0+sqrt(R^2-x0^2)) )/(3*A_Ch) -y0



Po_u = [s*(s^2-1),0,6*A_Ch*(s^2-1),12*A_Ch*(s*Cy_Ch+Cx_Ch)]



Centroid of Circular Segment



Equation Derivation







share|cite|improve this question





















  • "What is the best circular arc which splits the circle in to two regions" - did you mean square? From your image it looks like the square is being split.
    – null
    Jul 16 at 21:44











  • I updated my question. Yes, it is the square I need to split.
    – AppoopanThaadi
    Jul 16 at 22:03










  • Note that it could well be that the circular arc closes all the way to a circle nearly centered on one point.
    – Joseph O'Rourke
    Jul 16 at 22:53










  • Yes, that is also a case of interest. But I do have methods to detect that case when complete circle(bubble) is inside the square and hence easy to solve. The scenario here is like this, two regions are two fluids, and we want to approximate their interface from their centroids. so a bubble, exactly as you mentioned, is also an acceptable solution.
    – AppoopanThaadi
    Jul 16 at 23:10











  • First, you need to be able to solve the problem of given a circle (center and radius), find the centroid of the two regions. This seems non-trivial.
    – marty cohen
    Jul 17 at 2:24














up vote
1
down vote

favorite












I am looking for an analytic solution for the following problem. A unit square is given. Coordinates of two points inside the square are given. What is the best circular arc which splits the square in to two regions such that the given points are closest(least square error) to the centroids of regions?



Problem Explanation Figure



This problem came up due to the following scenario. Region 1 and Region 2 represents 2 fluids. The only information we know are the two centroids and their area density. I was previously splitting it with straight line but have only two degree of flexibility(slope and intercept) and my results were not satisfactory. So while moving to higher order I had options of quadratic and circular fit. I want to try circular fit because of its elegance and easiness to extrapolate to 3D as that is my final requirement.



My one of many attempts to tackle the problem was as following. I tried first to solve assuming there exists a circle as an exact solution for given inputs, Area, x and y (Area value is available)



a) consider two separate cases, arc cutting adjacent sides and diagonals.



b) connect ends of arc, find the centroid of circular segment and thus find equation for intersection area of circle and square.



c) Using area find equations for centroids.



d) solve 3 equations analytically(I could not see equations below) or numerically(I could do it in matlab)



But the draw backs are I cannot afford many iterations(millions of cells) and there are infinite cases when there is no solution for this cubic equation. In that case I need to differentiate the analytical term for error which I could not solve for even using software.



The 3 equations for one scenario was got like this (figure attached) this uses unknowns xo, yo and R for the equations with given inputs of area (A_Ch) and centroids (Cx_Ch and Cy_Ch)



gam = asin(y0/R);



del = acos(x0/R);



u = R*cos(gam)-x0;



v = R*sin(del)-y0;



s = -v/u



alpha = acos(x0/R)-asin(y0/R);
beta = acos(x0/R)+asin(y0/R);



A_Ch = 0.5 * ( R^2*alpha + 2*x0*y0 - y0*sqrt(R^2-y0^2) - x0*sqrt(R^2-x0^2) )



Cx_Ch = (2*R^3*(sin(alpha/2))^3 cos(beta/2)+0.5(sqrt(R^2-y0^2)-x0) * (sqrt(R^2-x0^2)-y0)*(2*x0+sqrt(R^2-y0^2)) )/(3*A_Ch) -x0



Cy_Ch = (2*R^3*(sin(alpha/2))^3 sin(beta/2)+0.5(sqrt(R^2-y0^2)-x0) * (sqrt(R^2-x0^2)-y0)*(2*y0+sqrt(R^2-x0^2)) )/(3*A_Ch) -y0



Po_u = [s*(s^2-1),0,6*A_Ch*(s^2-1),12*A_Ch*(s*Cy_Ch+Cx_Ch)]



Centroid of Circular Segment



Equation Derivation







share|cite|improve this question





















  • "What is the best circular arc which splits the circle in to two regions" - did you mean square? From your image it looks like the square is being split.
    – null
    Jul 16 at 21:44











  • I updated my question. Yes, it is the square I need to split.
    – AppoopanThaadi
    Jul 16 at 22:03










  • Note that it could well be that the circular arc closes all the way to a circle nearly centered on one point.
    – Joseph O'Rourke
    Jul 16 at 22:53










  • Yes, that is also a case of interest. But I do have methods to detect that case when complete circle(bubble) is inside the square and hence easy to solve. The scenario here is like this, two regions are two fluids, and we want to approximate their interface from their centroids. so a bubble, exactly as you mentioned, is also an acceptable solution.
    – AppoopanThaadi
    Jul 16 at 23:10











  • First, you need to be able to solve the problem of given a circle (center and radius), find the centroid of the two regions. This seems non-trivial.
    – marty cohen
    Jul 17 at 2:24












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am looking for an analytic solution for the following problem. A unit square is given. Coordinates of two points inside the square are given. What is the best circular arc which splits the square in to two regions such that the given points are closest(least square error) to the centroids of regions?



Problem Explanation Figure



This problem came up due to the following scenario. Region 1 and Region 2 represents 2 fluids. The only information we know are the two centroids and their area density. I was previously splitting it with straight line but have only two degree of flexibility(slope and intercept) and my results were not satisfactory. So while moving to higher order I had options of quadratic and circular fit. I want to try circular fit because of its elegance and easiness to extrapolate to 3D as that is my final requirement.



My one of many attempts to tackle the problem was as following. I tried first to solve assuming there exists a circle as an exact solution for given inputs, Area, x and y (Area value is available)



a) consider two separate cases, arc cutting adjacent sides and diagonals.



b) connect ends of arc, find the centroid of circular segment and thus find equation for intersection area of circle and square.



c) Using area find equations for centroids.



d) solve 3 equations analytically(I could not see equations below) or numerically(I could do it in matlab)



But the draw backs are I cannot afford many iterations(millions of cells) and there are infinite cases when there is no solution for this cubic equation. In that case I need to differentiate the analytical term for error which I could not solve for even using software.



The 3 equations for one scenario was got like this (figure attached) this uses unknowns xo, yo and R for the equations with given inputs of area (A_Ch) and centroids (Cx_Ch and Cy_Ch)



gam = asin(y0/R);



del = acos(x0/R);



u = R*cos(gam)-x0;



v = R*sin(del)-y0;



s = -v/u



alpha = acos(x0/R)-asin(y0/R);
beta = acos(x0/R)+asin(y0/R);



A_Ch = 0.5 * ( R^2*alpha + 2*x0*y0 - y0*sqrt(R^2-y0^2) - x0*sqrt(R^2-x0^2) )



Cx_Ch = (2*R^3*(sin(alpha/2))^3 cos(beta/2)+0.5(sqrt(R^2-y0^2)-x0) * (sqrt(R^2-x0^2)-y0)*(2*x0+sqrt(R^2-y0^2)) )/(3*A_Ch) -x0



Cy_Ch = (2*R^3*(sin(alpha/2))^3 sin(beta/2)+0.5(sqrt(R^2-y0^2)-x0) * (sqrt(R^2-x0^2)-y0)*(2*y0+sqrt(R^2-x0^2)) )/(3*A_Ch) -y0



Po_u = [s*(s^2-1),0,6*A_Ch*(s^2-1),12*A_Ch*(s*Cy_Ch+Cx_Ch)]



Centroid of Circular Segment



Equation Derivation







share|cite|improve this question













I am looking for an analytic solution for the following problem. A unit square is given. Coordinates of two points inside the square are given. What is the best circular arc which splits the square in to two regions such that the given points are closest(least square error) to the centroids of regions?



Problem Explanation Figure



This problem came up due to the following scenario. Region 1 and Region 2 represents 2 fluids. The only information we know are the two centroids and their area density. I was previously splitting it with straight line but have only two degree of flexibility(slope and intercept) and my results were not satisfactory. So while moving to higher order I had options of quadratic and circular fit. I want to try circular fit because of its elegance and easiness to extrapolate to 3D as that is my final requirement.



My one of many attempts to tackle the problem was as following. I tried first to solve assuming there exists a circle as an exact solution for given inputs, Area, x and y (Area value is available)



a) consider two separate cases, arc cutting adjacent sides and diagonals.



b) connect ends of arc, find the centroid of circular segment and thus find equation for intersection area of circle and square.



c) Using area find equations for centroids.



d) solve 3 equations analytically(I could not see equations below) or numerically(I could do it in matlab)



But the draw backs are I cannot afford many iterations(millions of cells) and there are infinite cases when there is no solution for this cubic equation. In that case I need to differentiate the analytical term for error which I could not solve for even using software.



The 3 equations for one scenario was got like this (figure attached) this uses unknowns xo, yo and R for the equations with given inputs of area (A_Ch) and centroids (Cx_Ch and Cy_Ch)



gam = asin(y0/R);



del = acos(x0/R);



u = R*cos(gam)-x0;



v = R*sin(del)-y0;



s = -v/u



alpha = acos(x0/R)-asin(y0/R);
beta = acos(x0/R)+asin(y0/R);



A_Ch = 0.5 * ( R^2*alpha + 2*x0*y0 - y0*sqrt(R^2-y0^2) - x0*sqrt(R^2-x0^2) )



Cx_Ch = (2*R^3*(sin(alpha/2))^3 cos(beta/2)+0.5(sqrt(R^2-y0^2)-x0) * (sqrt(R^2-x0^2)-y0)*(2*x0+sqrt(R^2-y0^2)) )/(3*A_Ch) -x0



Cy_Ch = (2*R^3*(sin(alpha/2))^3 sin(beta/2)+0.5(sqrt(R^2-y0^2)-x0) * (sqrt(R^2-x0^2)-y0)*(2*y0+sqrt(R^2-x0^2)) )/(3*A_Ch) -y0



Po_u = [s*(s^2-1),0,6*A_Ch*(s^2-1),12*A_Ch*(s*Cy_Ch+Cx_Ch)]



Centroid of Circular Segment



Equation Derivation









share|cite|improve this question












share|cite|improve this question




share|cite|improve this question








edited Jul 17 at 18:03
























asked Jul 16 at 21:30









AppoopanThaadi

1298




1298











  • "What is the best circular arc which splits the circle in to two regions" - did you mean square? From your image it looks like the square is being split.
    – null
    Jul 16 at 21:44











  • I updated my question. Yes, it is the square I need to split.
    – AppoopanThaadi
    Jul 16 at 22:03










  • Note that it could well be that the circular arc closes all the way to a circle nearly centered on one point.
    – Joseph O'Rourke
    Jul 16 at 22:53










  • Yes, that is also a case of interest. But I do have methods to detect that case when complete circle(bubble) is inside the square and hence easy to solve. The scenario here is like this, two regions are two fluids, and we want to approximate their interface from their centroids. so a bubble, exactly as you mentioned, is also an acceptable solution.
    – AppoopanThaadi
    Jul 16 at 23:10











  • First, you need to be able to solve the problem of given a circle (center and radius), find the centroid of the two regions. This seems non-trivial.
    – marty cohen
    Jul 17 at 2:24
















  • "What is the best circular arc which splits the circle in to two regions" - did you mean square? From your image it looks like the square is being split.
    – null
    Jul 16 at 21:44











  • I updated my question. Yes, it is the square I need to split.
    – AppoopanThaadi
    Jul 16 at 22:03










  • Note that it could well be that the circular arc closes all the way to a circle nearly centered on one point.
    – Joseph O'Rourke
    Jul 16 at 22:53










  • Yes, that is also a case of interest. But I do have methods to detect that case when complete circle(bubble) is inside the square and hence easy to solve. The scenario here is like this, two regions are two fluids, and we want to approximate their interface from their centroids. so a bubble, exactly as you mentioned, is also an acceptable solution.
    – AppoopanThaadi
    Jul 16 at 23:10











  • First, you need to be able to solve the problem of given a circle (center and radius), find the centroid of the two regions. This seems non-trivial.
    – marty cohen
    Jul 17 at 2:24















"What is the best circular arc which splits the circle in to two regions" - did you mean square? From your image it looks like the square is being split.
– null
Jul 16 at 21:44





"What is the best circular arc which splits the circle in to two regions" - did you mean square? From your image it looks like the square is being split.
– null
Jul 16 at 21:44













I updated my question. Yes, it is the square I need to split.
– AppoopanThaadi
Jul 16 at 22:03




I updated my question. Yes, it is the square I need to split.
– AppoopanThaadi
Jul 16 at 22:03












Note that it could well be that the circular arc closes all the way to a circle nearly centered on one point.
– Joseph O'Rourke
Jul 16 at 22:53




Note that it could well be that the circular arc closes all the way to a circle nearly centered on one point.
– Joseph O'Rourke
Jul 16 at 22:53












Yes, that is also a case of interest. But I do have methods to detect that case when complete circle(bubble) is inside the square and hence easy to solve. The scenario here is like this, two regions are two fluids, and we want to approximate their interface from their centroids. so a bubble, exactly as you mentioned, is also an acceptable solution.
– AppoopanThaadi
Jul 16 at 23:10





Yes, that is also a case of interest. But I do have methods to detect that case when complete circle(bubble) is inside the square and hence easy to solve. The scenario here is like this, two regions are two fluids, and we want to approximate their interface from their centroids. so a bubble, exactly as you mentioned, is also an acceptable solution.
– AppoopanThaadi
Jul 16 at 23:10













First, you need to be able to solve the problem of given a circle (center and radius), find the centroid of the two regions. This seems non-trivial.
– marty cohen
Jul 17 at 2:24




First, you need to be able to solve the problem of given a circle (center and radius), find the centroid of the two regions. This seems non-trivial.
– marty cohen
Jul 17 at 2:24















active

oldest

votes











Your Answer




StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "69"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2853880%2fhow-to-find-optimum-least-square-error-square-splitting-circular-arc-with-gi%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2853880%2fhow-to-find-optimum-least-square-error-square-splitting-circular-arc-with-gi%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

What is the equation of a 3D cone with generalised tilt?

Color the edges and diagonals of a regular polygon

Relationship between determinant of matrix and determinant of adjoint?