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 9277617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:09:08+00:00 2026-06-18T17:09:08+00:00

Using Python 2.7.3 and Pygame 1.9.1. I have a line and I only know

  • 0

Using Python 2.7.3 and Pygame 1.9.1.

I have a line and I only know the co-ordinates of endpoints A and B.
I want to calculate what are the co-ordinates AB, given a value on x or y axis.
For Example
Image Example

Here I know
(x,y) of A , B&C
Also,
C is on X-axis or Y axis.
My Question
How do I calculate the position of the Co-ordinates(x,y) of point D

  • 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-18T17:09:09+00:00Added an answer on June 18, 2026 at 5:09 pm

    The equation of the straight line is:

    y = mx + q
    

    What you want is either y(x) or x(y), and you have the two endpoints (x1, y1) and (x2, y2). Replace them in the straight-line equation and set up a linear system:

    y1 = m·x1 + q
    y2 = m·x2 + q
    

    Subtraction yields:

    y2-y1 = m(x2-x1) => m = (y2-y1)/(x2-x1)
    

    and q is obviously:

    q = y2-m·x2
    

    so, now you have your y = f(x) representing the straight line connecting your two points.

    Obviously, a vertical line cannot be represented in this form (m->+inf), and, if you are trying to trace a line on pixels evaluating this function for every x, you’ll get vertical “holes”.
    In both these cases, you should use the x = f(y) form (that you can obtain following these same steps, but starting from the equation x = py + r).

    That being said, you can get the y of D knowing its x by just putting such x in the equation of the straight line (y = f(x)) determined above; the same holds (with the inverse relation, x = f(y)) if you know the y and want to determine the x.

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

Sidebar

Related Questions

Using Python, I want to know whether Java is installed.
I'm using PyGame for Python, and have been receiving the following warning when loading
I'm currently making a game with Python using the PyGame module. I have two
Using Python v2.x, I have 3 variables that I want to ask the user
I'm working on a game. I have pygame imported. I am using Python 3.3
Is there any way to bind two windows from seprate processes together using Python/Pygame?
I am using python 2.7.1 with pygame 1.9.1 on 64-bit win7. I am using
Is there a way I can display text on a pygame window using python?
i am working on a program in Python and using Pygame. this is what
What is the correct way to use pygame.Color names when using unicode_literals ? Python

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.