I'm trying to write a bit of code that will calculate the values of X and Y as Q changes. I think I need to do this based on parametric equations because I need to plot vertical lines as well as other curves to find acceleration and velocity at different intervals and find the length of the path
The code below only contains the X Y and Q part of it that I don't know how to address. I can post the full code but its much longer. I believe it shows the actual problem I'm having.
I'm setting the start(Qo) and end(Qf) points of Q but I need to up date Qi based on the new position of X and Y. And this is what I don't know how to address
Time (T) is a fixed size ex .1. V and A have a starting value that is set by the user where V = input and A = gravity. Then the components of V and A change as the object moves along the path based on the slope at each point
The current program works great but only if X = Q which means it can't work for a vertical line
####################### input functions ############################
ParaFuncX = input("Enter a function: X(q) = ") # user inputs random
function
# EX: q, 2, q**2+6
ParaFuncY = input("Enter a function: Y(q) = ") # user inputs random
function
# EX: q**2, q, -q**3
F = sympy.sympify(ParaFuncX) # Turns parafuncX in to a usable expression
G = sympy.sympify(ParaFuncY) # Turns parafuncY in to a usable expression
################# Input parameters #############
yo = float(input("Enter yo = ")) # user inputs initial Y value
# EX: 25
print(yo)
print(solve(G - yo ,q)) # solves for Q values at Y = yo.
# EX: solves for roots at q**2 - 25 , q = -5,5
qo = float(input("From given values enter qo =")) # user inputs initial Q
value
# EX: -5
print(qo)
yf = float(input("Enter yf = ")) # user inputs final Y value
# EX: 9
print(yf)
print(solve(G - yf,q)) # solves for X values at Y = yf.
# EX: solves for roots at q**2 - 9 , q = -3 and 3
qf = float(input("From given values enter qf =")) # user inputs final q
value
# EX: 3
print(qf)
qi = qo
###################################################
# question start
def f(q): ## I thought defining the functions would help...
return ParaFuncX # some user input function that is ParaFuncX
#ex X = q , X = 2 etc
def g(q):
return ParaFuncY # some user input function that is ParaFuncY
#ex Y = q**2 , Y = q etc
while qi < qf
# V, A, T are variables found by knowing X and Y
X = f(qi) + V * T + .5 * Ax * T**2
Y = g(qi) + V * T + .5 * Ay * T**2
########## don't know how to do this ##########
Y_Q = # some solved value of q where g(q) = Y
X_Q = # some solved value of q where f(q) = X
########################################################
# X_Q and Y_Q should be the same in the real world
# so likely qi will have to equal ( (X_Q + Y_Q) / 2 )
# question end
#############################################