Be a Supporter!

Edits to post #25281346 by Etherblood

Back to Limit circle within circle AS3

Edited at 2014-11-02 00:54:54

At 11/1/14 11:52 PM, Sam wrote: It seems fairly heavy, though. I'm sure someone has a much more efficient solution.

Yup, there is no need to use an iterative approx.
Keeping circle1 with center c1 and radius r1 inside circle2 isn't really complex.

For circle1 to be inside circle2 the distance between their centers must smaller or equal than (r2 - r1).
The vector stuff I mentioned above would look like this:
(pseudocode, I used a vector 'class', can be replaced with its x and y parts though)

delta:vector = c1 - c2;            //delta is the vector from c2 to c1
distance:number = delta.length;     //distance is the distance between c1 and c2
                                      //the length of a vector is sqrt(x * x + y * y)
limit:number = r2 - r1;
if(limit < distance)
{
                                    //circle1 is not contained in circle2
    delta *= limit / distance;     //reduces the length of the delta vector to limit
    c1 = c2 + delta;                //moves circle1 to it's new contained position
}

Explaining is hard without pictures, if there are questions just ask.


At 11/1/14 11:52 PM, Sam wrote: It seems fairly heavy, though. I'm sure someone has a much more efficient solution.

Yup, there is no need to use an iterative approx.
Keeping circle1 with center c1 and radius r1 inside circle2 isn't really complex.

For circle1 to be inside circle2 the distance between their centers must smaller or equal than (r2 - r1).
The vector stuff I mentioned above would look like this:
(pseudocode, I used a vector 'class', can be replaced with its x and y parts though)

delta:vector = c1 - c2;            //delta is the vector from c2 to c1
distance:number = delta.length;     //distance is the distance between c1 and c2
                                      //the length of a vector is sqrt(x * x + y * y)
limit:number = r2 - r1;
if(limit < distance)
{
                                    //circle1 is not contained in circle2
    delta *= limit / distance;     //reduces the length of the delta vector to limit
    c1 = c2 + delta;                //moves circle1 to it's new contained position
}

If there are questions just ask.

Edited at 2014-11-02 00:54:42

At 11/1/14 11:52 PM, Sam wrote: It seems fairly heavy, though. I'm sure someone has a much more efficient solution.

Yup, there is no need to use an iterative approx.
Keeping circle1 with center c1 and radius r1 inside circle2 isn't really complex.

For circle1 to be inside circle2 the distance between their centers must smaller or equal than (r2 - r1).
The vector stuff I mentioned above would look like this:
(pseudocode, I used a vector 'class', can be replaced with its x and y parts though)

delta:vector = c1 - c2;            //delta is the vector from c2 to c1
distance:number = delta.length;     //distance is the distance between c1 and c2
                                      //the length of a vector is sqrt(x * x + y * y)
limit:number = r2 - r1;
if(limit < distance)
{
                                    //circle1 is not contained in circle2
    delta *= limit / distance;     //reduces the length of the delta vector to limit
    c1 = c2 + delta;                //moves circle1 to it's new contained position
}

I'm not good at explaining, if there are questions just ask.


At 11/1/14 11:52 PM, Sam wrote: It seems fairly heavy, though. I'm sure someone has a much more efficient solution.

Yup, there is no need to use an iterative approx.
Keeping circle1 with center c1 and radius r1 inside circle2 isn't really complex.

For circle1 to be inside circle2 the distance between their centers must smaller or equal than (r2 - r1).
The vector stuff I mentioned above would look like this:
(pseudocode, I used a vector 'class', can be replaced with its x and y parts though)

delta:vector = c1 - c2;            //delta is the vector from c2 to c1
distance:number = delta.length;     //distance is the distance between c1 and c2
                                      //the length of a vector is sqrt(x * x + y * y)
limit:number = r2 - r1;
if(limit < distance)
{
                                    //circle1 is not contained in circle2
    delta *= limit / distance;     //reduces the length of the delta vector to limit
    c1 = c2 + delta;                //moves circle1 to it's new contained position
}

Explaining is hard without pictures, if there are questions just ask.

Edited at 2014-11-02 00:52:38

At 11/1/14 11:52 PM, Sam wrote: It seems fairly heavy, though. I'm sure someone has a much more efficient solution.

Yup, there is no need to use an iterative approx.
Keeping circle1 with center c1 and radius r1 inside circle2 isn't really complex.

For circle1 to be inside circle2 the distance between their centers must smaller or equal than (r2 - r1).
The vector stuff I mentioned above would look like this:
(pseudocode, I used a vector 'class', can be replaced with its x and y parts though)

delta:vector = c1 - c2;          //delta is the vector from c2 to c1
distance:number = delta.length;     //distance is the distance between c1 and c2
                                        //the length of a vector is sqrt(x * x + y * y)
limit:number = r2 - r1;
if(limit < distance)
{
                                    //circle1 is not contained in circle2
    delta *= limit / distance;     //reduces the length of the delta vector to limit
    c1 = c2 + delta;                //moves circle1 to it's new contained position
}

I'm not good at explaining, if there are questions just ask.


At 11/1/14 11:52 PM, Sam wrote: It seems fairly heavy, though. I'm sure someone has a much more efficient solution.

Yup, there is no need to use an iterative approx.
Keeping circle1 with center c1 and radius r1 inside circle2 isn't really complex.

For circle1 to be inside circle2 the distance between their centers must smaller or equal than (r2 - r1).
The vector stuff I mentioned above would look like this:
(pseudocode, I used a vector 'class', can be replaced with its x and y parts though)

delta:vector = c1 - c2;            //delta is the vector from c2 to c1
distance:number = delta.length;     //distance is the distance between c1 and c2
                                      //the length of a vector is sqrt(x * x + y * y)
limit:number = r2 - r1;
if(limit < distance)
{
                                    //circle1 is not contained in circle2
    delta *= limit / distance;     //reduces the length of the delta vector to limit
    c1 = c2 + delta;                //moves circle1 to it's new contained position
}

I'm not good at explaining, if there are questions just ask.

Edited at 2014-11-02 00:52:17

At 11/1/14 11:52 PM, Sam wrote: It seems fairly heavy, though. I'm sure someone has a much more efficient solution.

Yup, there is no need to use an iterative approx.
Keeping circle1 with center c1 and radius r1 inside circle2 isn't really complex.

For circle1 to be inside circle2 the distance between their centers must smaller or equal than (r2 - r1).
The vector stuff I mentioned above would look like this:
(pseudocode, I used a vector 'class', can be replaced with its x and y parts though)

delta:vector = c1 - c2;          //delta is the vector from c2 to c1
distance:number = delta.length;     //distance is the distance between c1 and c2
                                                     //the length of a vector is sqrt(x * x + y * y)
limit:number = r2 - r1;
if(limit < distance)
{
                                           //circle1 is not contained in circle2
    delta *= limit / distance;     //reduces the length of the delta vector to limit
    c1 = c2 + delta;                //moves circle1 to it's new contained position
}

I'm not good at explaining, if there are questions just ask.


At 11/1/14 11:52 PM, Sam wrote: It seems fairly heavy, though. I'm sure someone has a much more efficient solution.

Yup, there is no need to use an iterative approx.
Keeping circle1 with center c1 and radius r1 inside circle2 isn't really complex.

For circle1 to be inside circle2 the distance between their centers must smaller or equal than (r2 - r1).
The vector stuff I mentioned above would look like this:
(pseudocode, I used a vector 'class', can be replaced with its x and y parts though)

delta:vector = c1 - c2;          //delta is the vector from c2 to c1
distance:number = delta.length;     //distance is the distance between c1 and c2
                                        //the length of a vector is sqrt(x * x + y * y)
limit:number = r2 - r1;
if(limit < distance)
{
                                    //circle1 is not contained in circle2
    delta *= limit / distance;     //reduces the length of the delta vector to limit
    c1 = c2 + delta;                //moves circle1 to it's new contained position
}

I'm not good at explaining, if there are questions just ask.

Edited at 2014-11-02 00:51:59

At 11/1/14 11:52 PM, Sam wrote: It seems fairly heavy, though. I'm sure someone has a much more efficient solution.

Yup, there is no need to use an iterative approx.
Keeping circle1 with center c1 and radius r1 inside circle2 isn't really complex.

For circle1 to be inside circle2 the distance between their centers must smaller or equal than (r2 - r1).
The vector stuff I mentioned above would look like this:
(pseudocode, I used a vector 'class', can be replaced with its x and y parts though)

delta:vector = c1 - c2;          //delta is the vector from c2 to c1
distance:number = delta.length;     //distance is the distance between c1 and c2
                                                                 //the length of a vector is sqrt(x * x + y * y)
limit:number = r2 - r1;
if(limit < distance)
{
                                                      //circle1 is not contained in circle2
    delta *= limit / distance;     //reduces the length of the delta vector to limit
    c1 = c2 + delta;                    //moves circle1 to it's new contained position
}

I'm not good at explaining, if there are questions just ask.


At 11/1/14 11:52 PM, Sam wrote: It seems fairly heavy, though. I'm sure someone has a much more efficient solution.

Yup, there is no need to use an iterative approx.
Keeping circle1 with center c1 and radius r1 inside circle2 isn't really complex.

For circle1 to be inside circle2 the distance between their centers must smaller or equal than (r2 - r1).
The vector stuff I mentioned above would look like this:
(pseudocode, I used a vector 'class', can be replaced with its x and y parts though)

delta:vector = c1 - c2;          //delta is the vector from c2 to c1
distance:number = delta.length;     //distance is the distance between c1 and c2
                                                     //the length of a vector is sqrt(x * x + y * y)
limit:number = r2 - r1;
if(limit < distance)
{
                                           //circle1 is not contained in circle2
    delta *= limit / distance;     //reduces the length of the delta vector to limit
    c1 = c2 + delta;                //moves circle1 to it's new contained position
}

I'm not good at explaining, if there are questions just ask.

Edited at 2014-11-02 00:51:39

At 11/1/14 11:52 PM, Sam wrote: It seems fairly heavy, though. I'm sure someone has a much more efficient solution.

Yup, there is no need to use an iterative approx.
Keeping circle1 with center c1 and radius r1 inside circle2 isn't really complex.

For circle1 to be inside circle2 the distance between their centers must smaller or equal than (r2 - r1).
The vector stuff I mentioned above would look like this:
(pseudocode, I used a vector 'class', can be replaced with its x and y parts though)

delta:vector = c1 - c2;     //delta is the vector from c2 to c1
distance:number = delta.length;     //distance is the distance between c1 and c2
     //the length of a vector is sqrt(x * x + y * y)
limit:number = r2 - r1;
if(limit < distance)
{
         //circle1 is not contained in circle2
    delta *= limit / distance;     //reduces the length of the delta vector to limit
    c1 = c2 + delta;     //moves circle1 to it's new contained position
}

I'm not good at explaining, if there are questions just ask.


At 11/1/14 11:52 PM, Sam wrote: It seems fairly heavy, though. I'm sure someone has a much more efficient solution.

Yup, there is no need to use an iterative approx.
Keeping circle1 with center c1 and radius r1 inside circle2 isn't really complex.

For circle1 to be inside circle2 the distance between their centers must smaller or equal than (r2 - r1).
The vector stuff I mentioned above would look like this:
(pseudocode, I used a vector 'class', can be replaced with its x and y parts though)

delta:vector = c1 - c2;          //delta is the vector from c2 to c1
distance:number = delta.length;     //distance is the distance between c1 and c2
                                                                 //the length of a vector is sqrt(x * x + y * y)
limit:number = r2 - r1;
if(limit < distance)
{
                                                      //circle1 is not contained in circle2
    delta *= limit / distance;     //reduces the length of the delta vector to limit
    c1 = c2 + delta;                    //moves circle1 to it's new contained position
}

I'm not good at explaining, if there are questions just ask.

Edited at 2014-11-02 00:51:04

At 11/1/14 11:52 PM, Sam wrote: It seems fairly heavy, though. I'm sure someone has a much more efficient solution.

Yup, there is no need to use an iterative approx.
Keeping circle1 with center c1 and radius r1 inside circle2 isn't really complex.

For circle1 to be inside circle2 the distance between their centers must smaller or equal than (r2 - r1).
The vector stuff I mentioned above would look like this:
(pseudocode, I used a vector 'class', can be replaced with its x and y parts though)

delta:vector = c1 - c2;//delta is the vector from c2 to c1
distance:number = delta.length;//distance is the distance between c1 and c2
//the length of a vector is sqrt(x * x + y * y)
limit:number = r2 - r1;
if(limit < distance)
{
    //circle1 is not contained in circle2
    delta *= limit / distance;//reduces the length of the delta vector to limit
    c1 = c2 + delta;//moves circle1 to it's new contained position
}

I'm not good at explaining, if there are questions just ask.


At 11/1/14 11:52 PM, Sam wrote: It seems fairly heavy, though. I'm sure someone has a much more efficient solution.

Yup, there is no need to use an iterative approx.
Keeping circle1 with center c1 and radius r1 inside circle2 isn't really complex.

For circle1 to be inside circle2 the distance between their centers must smaller or equal than (r2 - r1).
The vector stuff I mentioned above would look like this:
(pseudocode, I used a vector 'class', can be replaced with its x and y parts though)

delta:vector = c1 - c2;     //delta is the vector from c2 to c1
distance:number = delta.length;     //distance is the distance between c1 and c2
     //the length of a vector is sqrt(x * x + y * y)
limit:number = r2 - r1;
if(limit < distance)
{
         //circle1 is not contained in circle2
    delta *= limit / distance;     //reduces the length of the delta vector to limit
    c1 = c2 + delta;     //moves circle1 to it's new contained position
}

I'm not good at explaining, if there are questions just ask.

Edited at 2014-11-02 00:49:49

At 11/1/14 11:52 PM, Sam wrote: It seems fairly heavy, though. I'm sure someone has a much more efficient solution.

Yup, there is no need to use an iterative approx.
Keeping circle1 with center c1 and radius r1 inside circle2 isn't really complex.

For circle1 to be inside circle2 the distance between their centers must smaller or equal than (r2 - r1).
The vector stuff I mentioned above would look like this:
(pseudocode)

delta:vector = c1 - c2;//delta is the vector from c2 to c1
distance:number = delta.length;//distance is the distance between c1 and c2
//the length of a vector is sqrt(x * x + y * y)
limit:number = r2 - r1;
if(limit < distance)
{
    //circle1 is not contained in circle2
    delta *= limit / distance;//reduces the length of the delta vector to limit
    c1 = c2 + delta;//moves circle1 to it's new contained position
}

I'm not good at explaining, if there are questions just ask.


At 11/1/14 11:52 PM, Sam wrote: It seems fairly heavy, though. I'm sure someone has a much more efficient solution.

Yup, there is no need to use an iterative approx.
Keeping circle1 with center c1 and radius r1 inside circle2 isn't really complex.

For circle1 to be inside circle2 the distance between their centers must smaller or equal than (r2 - r1).
The vector stuff I mentioned above would look like this:
(pseudocode, I used a vector 'class', can be replaced with its x and y parts though)

delta:vector = c1 - c2;//delta is the vector from c2 to c1
distance:number = delta.length;//distance is the distance between c1 and c2
//the length of a vector is sqrt(x * x + y * y)
limit:number = r2 - r1;
if(limit < distance)
{
    //circle1 is not contained in circle2
    delta *= limit / distance;//reduces the length of the delta vector to limit
    c1 = c2 + delta;//moves circle1 to it's new contained position
}

I'm not good at explaining, if there are questions just ask.

Edited at 2014-11-02 00:48:47

At 11/1/14 11:52 PM, Sam wrote: It seems fairly heavy, though. I'm sure someone has a much more efficient solution.

Yup, there is no need to use an iterative approx.
Keeping circle1 with center c1 and radius r1 inside circle2 isn't really complex.

For circle1 to be inside circle2 the distance between their centers must smaller or equal than (r2 - r1).
The vector stuff I mentioned above would look like this:
(pseudocode)

delta:vector = c1 - c2;//delta is the vector from c2 to c1
distance:number = delta.length;//the length of a vector is sqrt(x * x + y * y), distance is the distance between c1 and c2
limit:number = r2 - r1;
if(limit < distance)
{
    //circle1 is not contained in circle2
    delta *= limit / distance;//reduces the length of the delta vector to limit
    c1 = c2 + delta;//moves circle1 to it's new contained position
}

I'm not good at explaining, if there are questions just ask.


At 11/1/14 11:52 PM, Sam wrote: It seems fairly heavy, though. I'm sure someone has a much more efficient solution.

Yup, there is no need to use an iterative approx.
Keeping circle1 with center c1 and radius r1 inside circle2 isn't really complex.

For circle1 to be inside circle2 the distance between their centers must smaller or equal than (r2 - r1).
The vector stuff I mentioned above would look like this:
(pseudocode)

delta:vector = c1 - c2;//delta is the vector from c2 to c1
distance:number = delta.length;//distance is the distance between c1 and c2
//the length of a vector is sqrt(x * x + y * y)
limit:number = r2 - r1;
if(limit < distance)
{
    //circle1 is not contained in circle2
    delta *= limit / distance;//reduces the length of the delta vector to limit
    c1 = c2 + delta;//moves circle1 to it's new contained position
}

I'm not good at explaining, if there are questions just ask.