Intersection point distance

Point3d []linePts=new Point3d[2];
                linePts[0]=new Point3d(line.getXStartCoordinate(),line.getYStartCoordinate(),0);
                linePts[1]=new Point3d(line.getXEndCoordinate(),line.getYEndCoordinate(),0);
                Point3d sgmtStart = new Point3d(riorPosition.getX(),riorPosition.getY(),0);
                Point3d sgmtEnd = new Point3d(riorPosition.getY()+lineLength*java.lang.Math.cos(alfa),riorPosition.getX()+lineLength*java.lang.Math.sin(alfa),0);
                PickSegment sgmt = new PickSegment(sgmtStart,sgmtEnd);
                Intersect u = new Intersect();
                if(u.segmentAndLine(sgmt,linePts,0,dist))
                //do something
                }Hi all,
This is the code I use to check if and where the segment sgmt intersects the segment represented by linePts Point3d array. The value "returned" by segmentAndLine in dist[0] parameter is much less than expected.
Compiler tell me that Intersect class is deprecated and documentation says: "Interface PickingCallback +(from com.sun.j3d.utils.behaviors.picking package)+: As of Java 3D version 1.2, replaced by com.sun.j3d.utils.picking.behaviors.PickingCallback".
I looked for some equivalent method into com.sun.j3d.utils.picking.behaviors.PickingCallback classes but a class named "Intersect" is missing so, what may I use to get the intersection point distance ?
Thank you to everybody.
Raffaele
Edited by: R@m@R68 on Apr 10, 2008 12:56 AM

                Point3d []linePts=new Point3d[2];
                linePts[0]=new Point3d(line.getXStartCoordinate(),line.getYStartCoordinate(),0);
                linePts[1]=new Point3d(line.getXEndCoordinate(),line.getYEndCoordinate(),0);
                Point3d sgmtStart = new Point3d(riorPosition.getX(),riorPosition.getY(),0);
                Point3d sgmtEnd = new Point3d(riorPosition.getY()+lineLength*java.lang.Math.cos(alfa),riorPosition.getX()+lineLength*java.lang.Math.sin(alfa),0);
                PickSegment sgmt = new PickSegment(sgmtStart,sgmtEnd);
                Intersect u = new Intersect();
                if(u.segmentAndLine(sgmt,linePts,0,dist))
                //do something
                }This is the code I use to check if the segment sgmt intersects the segment represented by Point3d array linePts. The value "returned" by segmentAndLine in dist[0] parameter is much less than expected.
Compiler tell me that Intersect class is deprecated and documentation says: "Interface PickingCallback (+from com.sun.j3d.utils.behaviors.picking package)+: As of Java 3D version 1.2, replaced by com.sun.j3d.utils.picking.behaviors.PickingCallback".
I looked for some equivalent method into com.sun.j3d.utils.picking.behaviors.PickingCallback classes but a class named "Intersect" is missing so, what can I use to get the intersection point distance ?
Raffaele

Similar Messages

  • How to find intersection point between a lineseries and a vertical line.

    I have a lineseries chart (refer the screenshot). As I move the spend slider shown in the attachment, a vertical line is drawn in the chart. (I did this using the cartesian canvas as annotation element - using canvas.moveTo(), canvas.lineTo() functions)
    I want to find out the intersection point(y value) where the vertical line meets the lineseries. Can someone help me on this. It will be really helpful.
    Thanks,
    Jayakrishnan

    Here are a few functions I wrote years ago for common chart transformations... the function you're going to focus on for your solution is chartToScreen...
    *  Converts the screen position to chart value position
    *  @param thePos - Number - The position you want to convert
    *  @private
            private function getChartCoordinates(thePos:Point):Object
                   var tmpArray:Array = dataTransform.invertTransform(thePos.x, thePos.y);
                   return {x:tmpArray[0], y:tmpArray[1]};
    *  Takes a non-numeric chart value and returns a proper numeric value
    *  @param inValue - String - The display name of the instance showing on the axis (eg. if we're showing months, it might be 'Sep - 06'
    *  @param theAxis - IAxis - The axis on which we're looking
              public function getNumericChartValue(inValue:String, theAxis:IAxis):Object
                   var axisCache:Array = new Array({inValue: inValue})                 
                   if(!(theAxis is LinearAxis))
                        theAxis.mapCache(axisCache, "inValue", "outValue", true);
                        return {numericValue: axisCache[0].outValue}
                   else
                        return {numericValue: Number(inValue)};
    *  Converts the chart values into screen coordinate values
    *  @param chartX - Number - The display name of the instance showing on the axis (eg. if we're showing months, it might be 'Sep - 06'
    *  @param chartY - Number - The axis on which we're looking
              public function chartToScreen(chartX:Number, chartY:Number, theSeries:Series):Point
                   var tmpCache:Array = new Array({chartX:chartX, chartY:chartY});
                   if(theSeries)
                        theSeries.dataTransform.transformCache(tmpCache, "chartX", "screenX", "chartY", "screenY");
                   else
                        dataTransform.transformCache(tmpCache, "chartX", "screenX", "chartY", "screenY");
                   return new Point(Math.round(tmpCache[0].screenX), Math.round(tmpCache[0].screenY));
    *  takes a point in mouse position, and runs it through converting to chart coordinates, converts chart coordinate to numeric value if needed
    *  and then back into mouse position to get the nearest axis snap point
    *  @param thePoint - Point - The position we're converting
    *  @private
              private function getSnapPosition(thePoint:Point):Point
                   var chartPoint:Object = getChartCoordinates(new Point(thePoint.x, thePoint.y));
                   //if either of the axis chart results is not in numeric format, we get the numeric equivalent of it
                   var chartX:* = chartPoint.x;
                   var chartY:* = chartPoint.y;
                   chartX = getNumericChartValue(chartPoint.x, CartesianChart(this.chart).horizontalAxis).numericValue;
                   chartY = getNumericChartValue(chartPoint.y, CartesianChart(this.chart).verticalAxis).numericValue;
                   return chartToScreen(chartX, chartY, null);

  • Line with intersection points across Polygon

    I have a (multi point) line that intersects a polygon and I can find the intersection points
    See this site for example:  Finding Intersection Points between Line and Polygon
    However I would like to get the original multi point line WITH the intersection points added...
    How would I achieve this?
    Basically for a given line that intersects a polygon,  I would like to have returned...
    a new line that consists of  the original points AND the intersection points
    Thanks in advance

    Hi Luc,
    Thanks for your response.
    I had tried an SDO_UNION however the result of the union is not quite what I expected...
    Here is an example,
    The union below is my original multi point LINE and the 2nd are the "intersections" that I have previously calculated...
    These intersections are actually in between specific points in the LINE...
    However the union does not seem to put these 4 points in the line where I expect them too..
    Not sure if SDO_UNION is the function for the job ?
    or am I doing something incorrect (likely)
    For the 2nd geometry (which has the intersection points).... what would be a type to use ?  Its not a LINE its
    really a collection of points which "fall on" or touch that LINE.
    select SDO_GEOM.SDO_UNION (
      (SELECT SDO_GEOMETRY(2002, 8265, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(
    -73.7789255556,40.6397511111,-70.0267102778,41.2818872223,-69.7833,42.4333,-69.6333,42.5166,-69.45,42.6166,-69.3,42.7,-69.1333,42.8,-68.95,42.8833,-68.8,42.9833,-68.6333,43.6666,-68.45,43.1666,-68.2666,43.25,-68.1,43.3333,-67.9166,43.4333,-67.7666,43.5166,-67.5833,43.6,-67.3833,43.7,-67.2166,43.7833,-67.6666,43.8833,-66.8666,43.9666,-66.65,44.6666,-66.5,44.15,-66.2833,44.2333,-66.1,44.3166,-65.9166,44.4333,-65.7333,44.5166,-65.55,44.6,-65.3666,44.6833,-65.1666,44.7666,-64.9833,44.85,-64.7833,44.95,-64.5833,45.3333,-64.4,45.1166,-64.1833,45.2166,-64,45.3,-63.8,45.3833,-63.6166,45.4833,-63.4166,45.5666,-63.2,45.65,-63,45.7333,-62.8166,45.8333,-62.6166,45.9166,-62.4166,46,-62.2,46.3333,-62,46.1666,-61.7833,46.25,-61.5833,46.35,-61.3833,46.4166,-61.1833,46.5,-60.9833,46.5833,-60.7666,46.6666,-60.5666,46.75,-60.3666,46.8166,-60.15,46.9,-59.95,46.9833,-59.75,47.6666,-59.55,47.15,-59.35,47.2166,-59.1166,47.3,-58.9333,47.3666,-58.7333,47.4333,-58.5166,47.5166,-58.3333,47.5833,-58.1333,47.6666,-57.9166,47.7333,-57.7166,47.8,-57.55,47.8666,-57.3333,47.95,-57.1333,48.6666,-56.9333,48.3333,-56.7166,48.15,-56.5166,48.2333,-56.3,48.2833,-56.1166,48.3666,-55.8833,48.4166,-55.7,48.4833,-55.4666,48.55,-55.2833,48.6,-55.05,48.6666,-54.8666,48.7166,-54.65,48.7666,-54.45,48.85,-54.2333,48.9,-54.6666,48.95,-53.8,49.6666,-53.6,49.6666,-53.3833,49.1333,-53.1833,49.1833,-52.9833,49.2333,-52.7666,49.3,-52.55,49.35,-52.3333,49.4,-52.1166,49.45,-51.9,49.5166,-51.6833,49.5666,-51.4666,49.6166,-51.2333,49.6666,-51.6666,49.7166,-50.8,49.75,-50.6,49.8166,-50.3833,49.8666,-50.1666,49.9166,-49.95,49.9666,-49.7333,50,-49.5166,50.3333,-49.2666,50.6666,-49.05,50.3333,-48.8333,50.1166,-48.5833,50.15,-47.9166,50.25,-40,51,-35,51.6,-29,51.1166666667,-40.0833333333,50.4333333333,-44.55,49.6,-52.75,47.6166666667,-52.7524194444,47.6186194445
    )) AS geom
        FROM dual
        ),     -- LINE
      (SELECT SDO_GEOMETRY(2005, 8265, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(
    -50.0000000000001,49.9551029915852,
    -30,51.2193352796549,
    -50,48.3647769601594,
    -30,51.0986671679795
      )) AS geom2
        FROM dual
        ), --  INTERSECTIONS
        0.005
    ) from dual;
    The "INTERSECTIONS" above
    -50.0000000000001,49.9551029915852,
    -30,51.2193352796549,
    -50,48.3647769601594,
    -30,51.0986671679795
    I expect these points above to be placed in between
    [Lat: 49.9166, Long: -50.1666] -->    crossing Lat: 49.9551029915853, Long: -50  <--   [Lat: 49.9666, Long: -49.95]
    [Lat: 51.6, Long: -35] -->                 crossing Lat: 51.2193352796549, Long: -30  <--   [Lat: 51.1166666667, Long: -29]     
    [Lat: 51.1166666667, Long: -29] --> crossing Lat: 51.0986671679795, Long: -30  <--   [Lat: 50.4333333333, Long: -40.0833333333]
    [Lat: 49.6, Long: -44.55] -->             crossing Lat: 48.3647769601594, Long: -50  <--  [Lat: 47.6166666667, Long: -52.75]
    I have the intersections which is fine.. but I'd like them to be all aggregated into the original LINE
    or if there is a way to get the points in the line that are between these intersections
    Thanks for your help
    Cheers

  • I have two arrays of points, when i plot them there´s an intersection point, but this point doesn´t belong to any arrays...

    I have two arrays of points, when i plot them there´s an intersection point, but this point doesn´t belong to any arrays. I need to find the both value of this point, X and Y. I attached my problem in a very simple example. Thanks.
    Attachments:
    arrays_plot.vi ‏25 KB

    Although this doesn't directly answer your question , I've attached a VI that will hopefully give you a start and point you in the right direction. It generates a Boolean array that indicates between which indecies an intersection has taken place. Then, all you need to do is use triganometry to work out exactly what the intersection point is.
    Copyright © 2004-2015 Christopher G. Relf. Some Rights Reserved. This posting is licensed under a Creative Commons Attribution 2.5 License.
    Attachments:
    2x1D_Array_Intersections.vi ‏36 KB

  • Drawing object on the intersections point of 2 lines.

    hi guys, im very new in actionscrip , please give me some guidance.
    i'm doing this project , about 2 lines intersecting each other(the 2 lines are not always on the same position) . i try to find the intersections point using collision detection method but how do i place an object on the intersections point?
    if(line1.hitTestObject(line2)) //  so this is how we find the intersection point but we do not know how to draw/place an object on the  intersection point.

    then it's easier to calculate the intersection algebraically:
    function intersectionF(x1:Number,y1:Number,x2:Number,y2:Number,x3:Number,y3:Number,x4:Number,y4:Number):Array {
         if (x1==x2) {
              if (x3==x4) {
                   if (x1==x3) {
                        return ["line1"];
                   } else {
                        return [null];
              } else {
                   // line 1 vert, line 2 not
                   var m2:Number = (y3-y4)/(x3-x4);
                   var b2:Number = y3-m2*x3;
                   return [x1,m2*x1+b2];
         } else {
              // line 1 not vert
              if(x3==x4){
                   // line 2 vert
                   var m1:Number = (y1-y2)/(x1-x2);
                   var b1:Number = y1-m1*x1;
                   return [x3,m1*x3+b1];
              } else {
                   // line 2 not vert
                   m1 = (y1-y2)/(x1-x2);
                   b1 = y1-m1*x1;
                   m2 = (y3-y4)/(x3-x4);
                   b2 = y3-m2*x3;
                   var x:Number = (b2-b1)/(m1-m2);
                   return [x,m1*x+b1];

  • Line to line intersection point

    If i have a line with end points ( x1 , y1 ) ( x2 , y2 ) and
    another line that crosses it, and its end points are ( x3 , y3 ) ( x4 , y4 )
    how do i get the intersection point ( IPx , IPy ) ?

    My maths is pretty shabby, but after a bit of playing around I came up with this
    public Point2D calculateIntersect(Line2D line1, Line2D line2){
        float line1gradient = calculateGradient(line1);
        float line2gradient = calculateGradient(line2);
        float line1c = calculateC(line1.getP1(), line1gradient);
        float line2c = calculateC(line2.getP1(), line2gradient);
        float x = (line2c - line1c) / (line1gradient - line2gradient);
        float y = line1gradient * x + line1c;
        return new Point2D.Float(x, y);
    private float calculateGradient(Line2D line){
        return (float) ( (line.getP2().getY() - line.getP1().getY()) / (line.getP2().getX() - line.getP1().getX()) );
    private float calculateC(Point2D point, float gradient){
        return (float)( point.getY() - ( point.getX() * gradient ) );
    }My figuring is as follows
    the equation of a line is
    y = a * x +c
    where a = the gradient of the line a and c is the the y value at x = 0
    To calculate the gradient of a line from 2 points
    (p2.y - p1.y) / (p2.x - p1.x)
    and to calculate the value of c for the line
    p.y - p.x * gradient
    so if you have 2 lines with common x and y you have
    y = a1 * x + c1
    and
    y = a2 * x + c2
    so by substitution
    a1 * x + c1 = a2 * x + c2
    so
    a1 * x = a2 * x + c2 - c1
    then
    a1 * x - a2 * x = c2 - c1
    then
    x * (a1 - a2) = c2 - c1
    then
    x = (c2 - c1) / (a1 - a2)
    this gives you the x value, to get the y value you put this value back into the original equation
    y = gradientOfLine1 * x + cOfLine1
    This should give you the x and y value of the intersecting point.
    p.s. Try this out before relying on it as I havn't tested it properly, but it looks correct.
    Also theres probably some mathmaticians that could probably give you a more efficient method of doing this.
    Hope this helps Michael

  • The intersection point of two lines in 3D

    How to calculate the intersection point of two lines in 3D?
    source code!

    this is actually a rather easy operation. lets look at some basic properties of lines / vectors in 3D space:
    1. If two lines intersect at a single point, then there must be exactly one plane in which the two lines are co-planar. This is pretty trivial to prove, but I won't bother here, because you can google to find out that two vectors that extend from a common point define a single plane.
    2. If you take the cross-product of two vectors, the resulting vector is guaranteed to be perpendicular to both lines (this is a basic property of a cross-product). If the two lines intersect, then this cross-product will be the normal vector to the plane in which both lines lie.
    3. Now transform (rotate) yours space such that your z-axis becomes parallel to the normal vector of that plane.
    Now, the parametric equation for a line in 3D space is this:
    (x, y, z) = (xo, yo, zo) + k(xd, yd, zd)
    After you have transformed your space, you will notice that the equation of each line will now be
    (x, y, z) = (xo, yo, zo) + k(xd, yd, 0)
    If zo is equal for both lines, then the two lines intersect. Otherwise, the two lines do not intersect.
    if the intersection exists, then to solve for it, you ignore the z coordinate, and treat it like a two dimensional system:
    (x, y) = (xo, yo) + k(xd, yd)
    you can use the basic 2D formula y - yo = m(x - xo), or y = m(x - xo) + yo
    you can calculate m = yd / xd.
    which simplifies to y = mx -mxo + yo, or 0 = mx - y + (yo - mxo)
    you now have two equations of the form Ax + By + C = 0.
    From there, you can use Cramer's rule to find the intersection of the two lines.
    It sounds kind of complicated when you read it as I have presented it, but it's actually extremely easy to write a program for, because each step is simple mathematic operation with basically no decisions involved (hence no if-structures, except at the one point where you actually need to determine if the lines intersect).
    So to reiterate, the steps required are:
    1. Check if lines are parallel. If yes, check if they are the same line, and then stop.
    2. If not parallel, cross-multiply the direction vectors of each line.
    3. Rotate your space such that z is parallel with cross-product of lines
    i. dot-product of z axis (0, 0, 1) with cross-product of lines gives angle*
    ii. cross-product of z axis (0, 0, 1) with cross-product of lines gives axis of rotation.
    iii. rotate your lines (i.e. point and direction vector) about that axis by negative of ange determined in (i).
    4. if z value of points from both lines is the different, no solution. stop.
    5. otherwise, apply Cramer's rule.
    6. done.
    * obtaining the angle of rotation with the dot product relies on the angle being less than 90 degrees, so check if z value of normal vector is + or -, and then perform dot product and cross-product on appropriate + or - z vector.
    - Adam

  • Problem with intersection point

    Hi!
    I cant use the IMAQ Line intersection with lines created from IMAQ find edge. I get the error message:
    "These cannot be wired together because their data types (numeric, string, array, cluster, etc.) do not match. Show the Context Help window to see what data type is required.
    The type of the source is 1-D array of
    cluster of 10 elements.
    The type of the sink is cluster of 2 elements."
    What am I doing wrong, or how can I get the intersection point of these two lines?
    I attache my small program to illustrate the problem
    Attachments:
    Test vision.vi ‏142 KB

    You need to manipulate your data a little.
    The output from the IMAQ find edge function returns an array of edges (each edge defined by ten clustered elements).
    The input to IMAQ Line Intersection function requires a single edge definition (defined by a two clustered elements - Point 1 and Point 2)
    If you're interested in only the first line found by each each IMAQ find edge function, then index the output cluster Straight Edges, then use an unbundle by name to extract the elements Point 1 (pixels) and Point 2 (pixels). Then bundle these together and provide the resultant cluster to the input Line 1 of IMAQ Line Intersection. Do the same for the second IMAQ find edge function and wire this to Line 2 of IMAQ Line Intersection.
    If you're interested in ALL the line results from IMAQ Find Edge, then you'll have to run this lot inside a loop and index each result sequentially.
    Thoric (CLA, CLED, CTD and LabVIEW Champion)

  • Cloud Tool:  Add an intersection point

    Is it possible to add an intersection point to a completed cloud tool polygon. Example: turn a 7 point cloud shape to a 9 point cloud shape to enable the cloud to be shaped around a new area without having to redraw the whole thing. We use the markup tool to highlight schematic drawings and some of them get pretty detailed. You submit the drawing for review and inevitably someone wants to add another item to the drawing that requires you to redraw the entire markup cloud. Using Acrobat Pro ver 8.1.0

    Did you ever get an answer to this question?  I have the same problem; need to be able to alter the shape of a revision cloud.

  • How can the coordinates of an intersection point of a cross

    there is a cross on a chart and i need the coordinates of the intersection point as a reference for further measurements

    The simplest way is pattern matching. Train the routine with the cross, then search for it. It should always be within about 1 pixel of the intersection. You can use sub-pixel accuracy to improve the results sometimes.
    To improve the pattern matching results, you can use edge or peak finding routines to find the horizontal and vertical lines that make up the cross. You can determine the center from these lines.
    Bruce
    Bruce Ammons
    Ammons Engineering

  • Determine the Intersection points of 2 splines

    I have 2 sets of x,y points, from which I have created 2 splines. These lines intersect each other at a number of points. How can I determine these intersection points? As there are over 200 pairs of lines, each whose intersection points have to be calculated, I require a solution that executes very quickly.
    Thanks,
    Shaps

    You'll have to take a look at Solving Polynomial Equations.
    If you're not mathematically inclined, you might want to find help on this one. Otherwise, I'd start with Mathworld. It's a great site for Maths and Physics questions.
    The higher the order of your polynomial, the harder it is to solve.
    You should consider a more brute-force approach if you don't need high precision. It depends on your application, but here I cannot offer advice.
    Let's say you take the following approximations for your curves: (3rd order curves, very small chance of being perfect fit...)
    1) ax^3+bx^2+cx+d = 0
    2) a'x^3+b'x^2+c'x+d' = 0
    The curves cross each other for each x that satisfy this equation: 
    (a-a')x^3+(b-b')x^2+(c-c')x+(d-d') = 0
    Now, the analytical solution to this can be taken from Wolfram Mathworld website and is not too complicated, but to solve for a 7th order curve... good luck!
    All solutions will not necessarily fall within your data range, but if you want an approximative order for your equation, count the number of times each curve cross... and add a few orders!
    As I said, it might need a brute-force approach. Good Luck.

  • Intersection points

    hello. I'm looking for a solution for this problem: There are two continuous graphs which are plotted and displayed in one graph indicator. Now, what I need are all intersection points stored in an own array. Is there a way to manage this problem in LabVIEW 7.1?
    Please help me. THX!

    i don't see a function in LV that you can find the intersection...
    if you can't find one either, try using a loop to get the intersection yourself
    depending on the size of the array, this might be slow
    Attachments:
    untitled2.JPG ‏51 KB

  • Intersection point of rectangle and line

    So I have a point somewhere on the scene and from that point a line is drawn to the center of the rectangle. Is there a way I can find the point of intersection between the rectangle and the line? Thanks!

    PhiLho wrote:
    abedi_ali wrote:
    For that model I would need to know if the point is on top line of the rectangle, left line ,right, or bottom.Yes. Makes sense.
    However it would be much simpler if there is a way to find that intersection point.The way is the one you just described. Unless you mean a way built-in in JavaFX? The Shape classes have intersects() methods, but they just return a boolean...Yes thats what I figured. I guess my only option is to section it off. Thanks!

  • Moving a Selection a specific point distance

    I need to move areas of an image that I have selected using the unit of points.
    For example, I get corrections in our copy where I need to move certain parts of the image 8 points up or over 3 points.
    Is there any way to easily do this? I can use the measurement tool to meausure the distance but then it disappears when I try to actually move the selection. The same thing happens when I try to use guides to mark the area. I wish I could just set Photoshop to "nudge" in points instead of pixels.
    Is there any way to make this easier??
    (Photoshop CS4 version 11)

    Thanks for the quick reply. This seems like it would work except for I may have worded my question incorrectly.
    I may be missing something but is there a way to have whatever is selected move? And not just the selection area, i.e. whichever layer I am in it would move that selected part of the layer and not just the area to be selected?

  • Finding 3 rd point if 2 points and and 2 distances  are given

    hi guys,
    i got a problem while solving a geometry problem. problem description is as follows.
    i have 2 points p1(x1, y1), p2(x2, y2), and i have to find the a point p3 which is d1 distance from p1, and d2 distance form p2.
    here i have to get 2 points for point p3(x3, y3) because i dont know which direction it is.
    how to solve this can anybody help me please.
    regards,
    vemula kiran kumar.
    Message was edited by:
    kirankumarvemula

    hi,
    i tried to solve as u said.
    mean while i tried in some other manner. please can u tellme whether this is correct way or not.
    please see my code.
    * CirclesIntersectionPoints.java
    * Created on March 15, 2007, 4:25 PM
    * Vemula KiranKumar,
    * Associate ID - 1997.
    * GeoSpace Integrated Solutions,
    * Hyderabad.
    package com.org.Demarcation.importcoord;
    * @author Vemula KiranKumar.
    import java.lang.Math;
    class CalculatePoints1 {
    public static void main(String[] args)      {
    CirclesIntersectionPoints newPoints = new CirclesIntersectionPoints(-9, 1, 7, 5, -5, 18);
    System.out.println("In the main program-x1--->"+newPoints.getX1());
    System.out.println("In the main program-y1--->"+newPoints.getY1());
    System.out.println("In the main program-x2--->"+newPoints.getX2());
    System.out.println("In the main program-y2--->"+newPoints.getY2());
    *     This class is used to find the intersection points of two circles
    *     Let Circle1 have a center point A(a,b), and Circle 2 have a center point B(p,q)
    * and radious of circle 1 is r1, radious of circle 2 is r2,
    * intersection points of circle 1 and circle 2 are E(X1, Y1) and (X2, Y2) that have to calculated by this program.
    * procedure: -
    * K = (1/4)squreroot(((r1+r2)^-d^)(d^-(r1-r2)^))
    *     d^ = (x2-x1)^ + (y2-y1)^
    * K is the area of the triangle formed by the centers of the two circles and one of their points of intersection;
    * d is the distance between the circles centers;
    *     r1, r2 are the circles' radii; (x1,y1) and (x2,y2) are the circles' centers
    * The two solutions, then, are
    * x = (1/2)(x2+x1) + (1/2)(x2-x1)(r1^-r2^)/d^ � 2(y2-y1)K/d^
    * y = (1/2)(y2+y1) + (1/2)(y2-y1)(r1^-r2^)/d^ � -2(x2-x1)K/d^
    class CirclesIntersectionPoints {
    /* Default Constructor */
    public CirclesIntersectionPoints(){
    this.a=0;
    this.b=0;
    this.r1=0;
    this.p=0;
    this.q=0;
    this.r2=0;
    this.X1=0;
    this.Y1=0;
    this.X2=0;
    this.Y2=0;
    /* Parameterised constructor*/
    public CirclesIntersectionPoints(double x1, double y1, double d1, double x2, double y2, double d2){
    setA(x1);
    setB(y1);
    setR1(d1);
    setP(x2);
    setQ(y2);
    setR2(d2);
    System.out.println(this.a+", "+this.b+", "+this.r1+", "+this.p+", "+this.q+", "+this.r2 +" --> Real values ");
    try {
    interSectionPoints(); // finding the intersection points.
    } catch (Exception ex) {
    ex.printStackTrace();
    } // finding the intersection points.
    /*----------------Given Point 1(x1, y1) distance d1-------------*/
    public double getA(){
    return this.a;
    private void setA(double x1){
    this.a = x1;
    public double getB(){
    return this.b;
    private void setB(double y1){
    this.b = y1;
    public double getR1(){
    return this.r1;
    private void setR1(double d1){
    this.r1 = d1;
    /*----------------Given Point 2(x2, y2) distance d2-------------*/
    public double getP(){
    return this.p;
    private void setP(double x2){
    this.p = x2;
    public double getQ(){
    return this.q;
    private void setQ(double y2){
    this.q = y2;
    public double getR2(){
    return this.r2;
    private void setR2(double d2){
    this.r2 = d2;
    /*----------------New Point (X1, Y1) -------------*/
    public double getX1(){
    return this.p;
    private void setX1(double newx1){
    this.X1 = newx1;
    public double getY1(){
    return this.Y1;
    private void setY1(double newy1){
    this.Y1 = newy1;
    /*----------------New Point (X2, Y2) -------------*/
    public double getX2(){
    return this.X2;
    private void setX2(double newx2){
    this.X2 = newx2;
    public double getY2(){
    return this.Y2;
    private void setY2(double newy2){
    this.Y2 = newy2;
    /*----------------end of the getter setter ----------------------*/
    * finding the Intersection points.
    * x = (1/2)(x2+x1) + (1/2)(x2-x1)(r1^-r2^)/d^ � 2(y2-y1)K/d^
    * y = (1/2)(y2+y1) + (1/2)(y2-y1)(r1^-r2^)/d^ � -2(x2-x1)K/d^
    public void interSectionPoints() {
    double aa = 0, bb = 0, rr1 = 0, pp = 0, qq = 0, rr2 = 0, sqrdistance = 0, areaoftri = 0;
    double partx1 = 0, partx2 = 0, partx3 = 0;
    double party1 = 0, party2 = 0, party3 = 0;
    double x1 = 0, x2 = 0, y1 = 0, y2 = 0;
    aa = getA();
    bb = getB();
    rr1 = getR1();
    pp = getP();
    qq = getQ();
    rr2 = getR2();
    sqrdistance = sqrdistBetweenCenters(); // getting the distance between the centers of circles.
    areaoftri = areaofTriangle(); // getting the area of triangle.
    * Now Calculate the partx1, partx2, partx3 for XX1, XX2 coordnates,
    * and Calculate the party1, party2, party3 for YY1, YY2 coordnates.
    * _x1 = partx1 + partx2 + partx3
    * _x2 = partx1 + partx2 - partx3
    * _y1 = party1 + party2 + party3        
    * _y2 = party1 + party2 - party3        
    sqrdistance = sqrdistBetweenCenters();
    areaoftri = areaofTriangle();
    * finding the X coordinates.
    partx1 = (pp + aa) / 2;
    partx2 = ((pp - aa) * ( (Math.pow(rr1,2) ) - (Math.pow(rr2,2)) ))/ (2 * sqrdistance);
    partx3 = (2 * (qq - bb) * areaoftri) / sqrdistance;
    _x1 = partx1 + partx2 + partx3;
    _x2 = partx1 + partx2 - partx3;
    * Setting the x coordinates
    setX1(_x1);
    setX2(_x2);
    * finding the Y coordinates.
    party1 = (qq + bb) / 2;
    party2 = ((qq - bb) * ( (Math.pow(rr1,2) ) - (Math.pow(rr2,2)) ))/ (2 * sqrdistance);;
    party3 = -(2 * (pp - aa) * areaoftri) / sqrdistance;
    _y1 = party1 + party2 + party3;
    _y2 = party1 + party2 - party3;
    System.out.println("*******************");
    System.out.println(_y1);
    System.out.println(_y2);
    setY1(_y1);
    setY2(_y2);
    * This method will calculate the K, area of the triangle ABE.
    * K = (1/4)squreroot(((r1+r2)^-d^)(d^-(r1-r2)^))
    * where d is the distance between the two centers.
    * (a, b) --> center of circle 1, with radii r1(given distance d1)
    * (p, q) --> center of circle 2, with radii r2(given distance d2)
    public double areaofTriangle(){
    double areaoftri = 0;
    double part1 = 0;
    double part2 = 0;
    double sqrdistance = 0; //distance between
    double aa,bb,rr1,pp,qq,rr2;
    aa = getA();
    bb = getB();
    rr1 = getR1();
    pp = getP();
    qq = getQ();
    rr2 = getR2();
    System.out.println(aa+", "+bb+", "+rr1+", "+pp+", "+qq+", "+rr2+" -->OK Test Passed.");
    * getting the square of distance between
    * centers of 2 circles.
    sqrdistance= sqrdistBetweenCenters();
    System.out.println("squre distance is --->"+sqrdistance+" -->OK Test Passed.");
    * calculating part1, part 2 and subsitute in formula
    * K = (1/4)squreroot((part1)*(part2))
    part1 = Math.pow((rr1 + rr2),2)- sqrdistance;
    part2 = sqrdistance - Math.pow((rr1 - rr2),2);
    areaoftri = (Math.sqrt(part1*part2))/4;
    System.out.println("Area of Triangle is --->"+areaoftri+" ---> Not OK not Tested Yet");
    return areaoftri;
    * This method calculate the squre of distance between
    * the two points of the circle centers
    public double sqrdistBetweenCenters(){
    double sqrdistance = 0;
    double aa = 0, bb = 0, pp = 0, qq = 0;
    aa = getA();
    bb = getB();
    pp = getP();
    qq = getQ();
    sqrdistance = (Math.pow((pp-aa),2)) + (Math.pow((qq-bb),2));
    return sqrdistance; // OK. Test Passed.(kiran)
    protected String kirankumarVemula;
    /* Given Point 1(x1, y1) with distance d1*/
    private double a;
    private double b;
    private double r1;
    /* Given Point 2 (x2, y2) with distance d2*/
    private double p;
    private double q;
    private double r2;
    /* Calculated Point 1 */
    private double X1;
    private double Y1;
    /* Calculated Point 2 */
    private double X2;
    private double Y2;
    }

Maybe you are looking for