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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:45:15+00:00 2026-05-29T16:45:15+00:00

I just can’t seem to spot my bug here, can you? bool oblong (vec2

  • 0

I just can’t seem to spot my bug here, can you?

bool oblong (vec2 p, vec2 a, vec2 b, float r) {
 return (((b.y-a.y)*(p.x-a.x)+(b.x-a.x)*(p.y-a.y))^2/((b.x-a.x)^2+(b.y-a.y)^2)<= r);
}

This is my second GLSL program, (my first was a circle.) Thanks for your input!

  • 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-29T16:45:18+00:00Added an answer on May 29, 2026 at 4:45 pm

    You don’t explain very well what the function is supposed to do and what your single-character variable names actually mean. I’m going to guess that a and b are the points on the line segment, and p is the point of interest. r must be some distance that the function tests against (generally, you should return the distance and let the user test against it. If they want to keep it, it’s there prerogative).

    I guess your real problem is that in neither C, C++, or GLSL is ^ the “raise to a power” operator.

    In any case, a correct version of this function would be as follows:

    float DistToLine(vec2 pt1, vec2 pt2, vec2 testPt)
    {
      vec2 lineDir = pt2 - pt1;
      vec2 perpDir = vec2(lineDir.y, -lineDir.x);
      vec2 dirToPt1 = pt1 - testPt;
      return abs(dot(normalize(perpDir), dirToPt1));
    }
    

    Note that this code has not been tested. I’m just implementing the solution presented at the given site. This is implemented in vector notation with vector arithmetic. Note that I very rarely get the X and Y components (I only do it once to get the perpendicular).

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

Sidebar

Related Questions

I'm new to regular expression and just can't seem to figure this out: '/^[A-Za-z0-9](?:.[A-Za-z0-9]+)$/'
I just can't seem to figure this one out... As far as I know,
ive browsed many articles here but I just can't make this work for the
I just can't seem to wrap my mind around this concept... I want to
i just can't seem to find a definitive answer to this issue, and django's
I just can't seem to get this working its been weeks I've been trying.
I just can't seem to figure this out - I'm trying to get the
I just can't seem to get this query figured out. I need to combine
I've googled and just can't seem to find the answer to this simple question.
I just can't understand why is my database (mysql) behaving like this! My console

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.