Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How do i plot a point in a slanting line

How do i plot a point in a slanting line

Scheduled Pinned Locked Moved C#
questioncsharp
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Laddie
    wrote on last edited by
    #1

    Hi guys, I have a scenirio where by i need create some circles with varying distance in the sides of a triangle on a Web Page where all the sides are equal. I have the points for all the three vertex. I know just because i am using C# for that this question does't belong here. But please let me know if you have any idea on this.. Thank you

    Thanks Laddie Kindly rate if the answer was helpful

    C 1 Reply Last reply
    0
    • L Laddie

      Hi guys, I have a scenirio where by i need create some circles with varying distance in the sides of a triangle on a Web Page where all the sides are equal. I have the points for all the three vertex. I know just because i am using C# for that this question does't belong here. But please let me know if you have any idea on this.. Thank you

      Thanks Laddie Kindly rate if the answer was helpful

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You work out the ratio of width to height and use that to calculate the x for a given y, or vice versa.

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      L 1 Reply Last reply
      0
      • C Christian Graus

        You work out the ratio of width to height and use that to calculate the x for a given y, or vice versa.

        Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        L Offline
        L Offline
        Laddie
        wrote on last edited by
        #3

        Hi Christian, Thank you for the reply. But it will work only if the line is straight. You mean to say new x = (Width - n) Right.. But here it is a slanting line. Like the sides of a triangle. Or may be i got you wrong ? Thank you Laddiw

        Thanks Laddie Kindly rate if the answer was helpful

        C 1 Reply Last reply
        0
        • L Laddie

          Hi Christian, Thank you for the reply. But it will work only if the line is straight. You mean to say new x = (Width - n) Right.. But here it is a slanting line. Like the sides of a triangle. Or may be i got you wrong ? Thank you Laddiw

          Thanks Laddie Kindly rate if the answer was helpful

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          You got me wrong. If x1=5, y1 = 10, x2 = 25, y2 = 50 then the ration is (25-5)/(50-10), or 20/40 or 1/2. So, if you want to know the y position when x is 10, you subtract 5, to get to your base line. Then you multiply 5 by 2. Then you add 10 ( your starting y ). So, 10,20 is a point on the line.

          Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          L 2 Replies Last reply
          0
          • C Christian Graus

            You got me wrong. If x1=5, y1 = 10, x2 = 25, y2 = 50 then the ration is (25-5)/(50-10), or 20/40 or 1/2. So, if you want to know the y position when x is 10, you subtract 5, to get to your base line. Then you multiply 5 by 2. Then you add 10 ( your starting y ). So, 10,20 is a point on the line.

            Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

            L Offline
            L Offline
            Laddie
            wrote on last edited by
            #5

            Ok. Looks like it should work..Let me try implementing the same and will come back. Thank you Have a nice day.

            Thanks Laddie Kindly rate if the answer was helpful

            1 Reply Last reply
            0
            • C Christian Graus

              You got me wrong. If x1=5, y1 = 10, x2 = 25, y2 = 50 then the ration is (25-5)/(50-10), or 20/40 or 1/2. So, if you want to know the y position when x is 10, you subtract 5, to get to your base line. Then you multiply 5 by 2. Then you add 10 ( your starting y ). So, 10,20 is a point on the line.

              Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

              L Offline
              L Offline
              Laddie
              wrote on last edited by
              #6

              Hi chris, I created a function something like this public void pointX(int x1, int y1, int x2, int y2, int dis,out float newX,out float newY) { float ygrad = y2 - y1; float xgrad = x2 - x1; ygrad /= 100; xgrad /= 100; newY = (dis * ygrad) + y1; newX = (dis * xgrad) + x1; } It is working fine... The requirement was that i need to draw some circles depending on some percentage, whose center will be an offset from the side of a triangle, where offset is the percentage. Any way thank you for that idea.. Have a nice day.

              Thanks Laddie Kindly rate if the answer was helpful

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups