0

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
         #############################################
Peter O.
  • 32,158
  • 14
  • 82
  • 96
chris
  • 21
  • 3
  • I don't really understand the question. It seems more a math problem than a code help question. – Terry Jan Reedy Dec 09 '15 at 18:17
  • I just figured it out i already had the answer to this question in my code. i just didnt realize i could use it to solve this problem too. but now its lead to another problem that i dont know how to figure out at the moment – chris Dec 10 '15 at 00:47
  • @chris If this is solved now, I suggest you either close your question or write an answer yourself, explaining the details. – MvG Dec 10 '15 at 21:17

0 Answers0