Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8685657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:37:59+00:00 2026-06-12T22:37:59+00:00

Please see the image. How can I get the two line intersection point(that is

  • 0

Please see the image. How can I get the two line intersection point(that is green rounded point)? I want to crop the inner part of the image. The closing path is any where in the line.

context = UIGraphicsGetCurrentContext();
CGContextBeginPath(context);
CGContextSetLineWidth(context, 1.0 * self.scale);
CGContextSetLineCap(context, kCGLineCapRound);
[[UIColor redColor] setStroke];

CGPoint firstPoint = CGPointFromString([self.touchPoints objectAtIndex:0]);
CGContextMoveToPoint(context, firstPoint.x, firstPoint.y);

for (NSString *pointString in self.touchPoints) {
    CGPoint point = CGPointFromString(pointString);
    CGContextAddLineToPoint(context, point.x, point.y);
}

CGContextStrokePath(context);

This code used for the draw the lines. Line drawing is working fine, cropping also working fine…But the intersection point is my major problem. Please help me.

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:38:00+00:00Added an answer on June 12, 2026 at 10:38 pm

    Idea, check for intersections beginning with firstline<>lastline, firstline<>secondlastline … firstline<>thirdline => secondline<>lastline etc. This should give you the outer most intersection.

    The following Code is not tested, but should help you with your problem.

    typedef struct {
        CGPoint startPoint;
        CGPoint endPoint;
    } Line;
    
    #define CGPointNULL CGPointMake(NAN, NAN)
    
    #define Line(_i_) {CGPointFromString(touchPoints[_i_-1]), CGPointFromString(touchPoints[_i_])};
    
    CGPoint LineIntersects(Line *first, Line *second) {
        int x1 = first->startPoint.x; int y1 = first->startPoint.y;
        int x2 = first->endPoint.x; int y2 = first->endPoint.y;
    
        int x3 = second->startPoint.x; int y3 = second->startPoint.y;
        int x4 = second->endPoint.x; int y4 = second->endPoint.y;
    
        int d = (x1-x2)*(y3-y4) - (y1-y2)*(x3-x4);
    
        if (d == 0) return CGPointNULL;
    
        int xi = ((x3-x4)*(x1*y2-y1*x2)-(x1-x2)*(x3*y4-y3*x4))/d;
        int yi = ((y3-y4)*(x1*y2-y1*x2)-(y1-y2)*(x3*y4-y3*x4))/d;
    
        return CGPointMake(xi,yi);
    }
    
    static inline BOOL CGPointIsValid(CGPoint p) {
        return (p.x != NAN && p.y != NAN);
    }
    
    - (CGPoint)mostOuterIntersection:(NSArray *)touchPoints {
        CGPoint intersection = CGPointNULL;
        int touchCount = [touchPoints count];
    
        for(int i = 1; i<touchCount; i++) {
            Line first = Line(i);
            for(int j = touchCount-1; j>i+1; j--) {
                Line last = Line(j);
                intersection = LineIntersects(&first, &last);
                if(CGPointIsValid(intersection)) {
                    break;
                }
            }
        }
        return intersection;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please see the image below As you can see I have a master page
Please see the attached image. I'm trying to change the color on the segmented
Please see here , at the end of the post, the 70px author image
Please see below: I tried using Absolute layout, but that's deprecated. I appreciate your
Please see: http://jasondaydesign.com/masonry_demo/ and click on the movemaine.com image I would like my transitions
I have a black and white image (or pdf) file, and want to get
Please see this This Image for a picture of the problem. I have a
Please see this: My code looks like this now: http://jsfiddle.net/Bd9Ut/ As you can see
I am trying to get Google maps to display an image I can use
(Problem solved, please see the updates) I have some files that have incorrect filenames

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.