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

  • SEARCH
  • Home
  • 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 6883691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:24:52+00:00 2026-05-27T05:24:52+00:00

i have question about finding maximum x or y-value in text file. This is

  • 0

i have question about finding maximum x or y-value in text file. This is necessary for point in polygon algorithm.
Polygons are entered in text file together with point, that is in or out polygon and together with number of lines of polygon.

For example:

5.0 4.0 6 1.0 1.0 4.0 0.0 6.0 3.0 7.0 6.0 3.0 7.0 0.0 4.0 1.0 1.0  

The point is [5.0 4.0], polygon has 6 lines and next are written points of polygon:

[1.0 1.0][4.0 0.0][6.0 3.0][7.0 6.0][3.0 7.0][0.0 4.0][1.0 1.0].

First is x-coordinate, second is y-coordinate.

I have procedure that tests the position of 2 lines. Now I have to combine this procedure with this one algorithm.

What i have is:open txt a read line of txt, then split it and save the values to variables

pointinp = open ("pointinp.txt", "r")  
for line in pointinp.readlines():  
    riadok = line.split()  
    j=3  
    for i in range (0,riadok[2]):  
        x1=float(riadok[0])  
        y1=float(riadok[1])  
        k1=float(riadok[i+j])  
        l1=float(riadok[i+(j+1)])  
        k2=float(riadok[i+(j+2)])  
        l2=float(riadok[i+(j+3)])  
        j=j+1  

Point coordinates is in x1 and y1, coordinates of other points are in k1,l1,k2,l2. Now i have to find maximum x and y coordinate from text file to save it to x2,y2.
So then I will have 2 lines [x1,y1][x2,y2] and [k1,l1][k2,l2] and then i will test position of these lines and this is necessary in point in polygon algorithm, where will be counted the intersection points.(intersection between created line containing point and each line of polygon)

  • 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-05-27T05:24:52+00:00Added an answer on May 27, 2026 at 5:24 am

    Findind the maximum x and y in the line is straightforward enough, you just need to be able to separate them out and apply the max() function to them. Fortunately python list indexing supports a step size, so you can easily pull out every other value:

    xvals=riadok[3::2]
    yvals=riadok[4::2]
    xmax=max(xvals)
    ymax=max(yvals)
    

    Finding the maximum in the file is a bit harder: for each line you can compare your local maximum to the largest figure found so far, and replace the latter with the former if it is greater:

    xtruemax=max(xtruemax,xmax)
    ytruemax=max(ytruemax,ymax)
    

    but you will find these figures slowly growing as you go further through your file. If you want the genuine largest value of x and y available right from line one then you will have to process your file in two passes, once to find the maximum x and y and once to apply your algorithm.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Have a question about finding html tags using Java and Regex. I am
I have a question about locking. This doesn't have to be only about record
I have a question about using new[] . Imagine this: Object.SomeProperty = new[] {string1,
I have a question about this question . I posted a reply there but
I have a simple question about finding a regular expression for a given language.
I have question regarding about finding subview using '.tags' in one UIView. for (UIView
Following on from this question about setting Culture, I have a similar issue with
This question is not so much about finding a solution as about getting an
I have question about NSView: Imagine a Custom View where the mouseDown, mouseDrag and
I have question about normalization. Suppose I have an applications dealing with songs. First

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.