Code:
#eg. point = (1,2) and eqn = (a,b,c) where the equation is ay bx c=0
def reflect( point, eqn ):
#tuples to list
new_p = list(point)
new_eqn = list(eqn)
#sub values
p = new_p[0]
q = new_p[1]
a = new_eqn[0]
b = new_eqn[1]
c = new_eqn[2]
#formula where p'=((a^2−b^2)−2b(aq c))/a^2 b^2
p_new = round((p*(a**2−b**2)−2*b*(a*q c))/(a**2 b**2),1)
q_new = round((q*(b**2−a**2)−2*a*(b*p c))/(a**2 b**2),1)
return p_new,q_new
error:
p_new = round((p*(a**2−b**2)−2*b*(a*q c))/(a**2 b**2),1)
^
SyntaxError: invalid character in identifier
Q: Why is the character invalid? When I plug this into pycharm, I also get errors that my #sub values are not being used.
CodePudding user response:
The "minus" symbol in your code isn't one, it is Symbole Unicode «−» (U 2212)
>> ord("−") # yours
8722
>> ord("-") # the real one
45
Fix that and it'll work
CodePudding user response:
You should use '-' character as subtraction operator instead of '−'.