1

I am creating line tool for sketchup and was running out of ideas of calculating the other point on a diamond. Essentially (with this line tool) you draw a line, and then at a set width, it creates a diamond shape based of the midpoints and the slope. I already calculated the first point using the midpoint, slope and distance. Now, i need to reflect that point over the line and find the other corner....I have found various formulas, but non are making sense. I was wondering if anyone here could help. Ill link to the 2 sources that I have actually tested, maybe im missing something.

http://mathworld.wolfram.com/Reflection.html

Algorithm for reflecting a point across a line

z = b - slope*a

var1 = (a + (m*(b-z)))

var2 = var1 / (1 + (slope**2))

xneg = 2*(var2) - a

yneg = 2*(var2)*slope - b + 2*z

Community
  • 1
  • 1
user1546594
  • 539
  • 1
  • 4
  • 4
  • How did you calculate the first point? Why can't you use the same method to calculate the second? – jva Jul 23 '12 at 18:44
  • I calculated the first point by using the pythagorean theorem essentially, and the formula for slope. Eventually you get a quadratic equation that equals the first point. I have tried reversing x and y coordinates, but it would be much easier with a equation that supersedes the first formula. – user1546594 Jul 23 '12 at 18:51
  • Isn't the algorithm from the second link (accepted answer) working? – jva Jul 23 '12 at 18:55
  • I did code that, but it didnt seem to work...let me post my algorithm – user1546594 Jul 23 '12 at 19:51
  • z = the Y intercept or "c" in the second hyperlink. A = x and b = y – user1546594 Jul 23 '12 at 19:52
  • Okay, I moved the code into the question – user1546594 Jul 23 '12 at 21:21

1 Answers1

0

Looks like it should be

var1 = (a + (slope*(b-z)))
jva
  • 2,797
  • 1
  • 26
  • 41