'''
Created on 12-Jul-2021

@author: rishi_priyansh
'''
import inspect
import traceback
import random
import pathlib

from xv.util import locatePath

from sympy import (symbols, Sum, Eq, UnevaluatedExpr as ueval, latex)

# _kinematics_helper
# KinematicsHelper

from xv.util import UtilClass

class KinematicsHelper(UtilClass):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        pass
    
    def get_points_with_labels(self, count = None):
        if count is None:
            count = random.randint()
        point_symbs = symbols('A, B, C, D, E, F, G')
        point_coords = []
        
        t = 0
        prev_s = 0

        while len(point_coords) < 6:
            t = t + 1
            if not random.choice([True, False]):
                continue
            s = random.randint(-2, 5) + prev_s
            point_coords.append((t, s))
            prev_s = s
            
            pass
        pass
    
    
    def _plot_time_vs_velocity(self):
        
        pass

    def get_problem_irodov_1_18(self, *args, **kwargs):
        """
        doc_style: xv_doc
        """
        
        a, b, c, d, e, f = symbols('a, b, c, d, e, f')
        v_a, v_b, v_c, v_d, v_e, v_f = symbols('v_a, v_b, v_c, v_d, v_e, v_f')
        t_a, t_b, t_c, t_d, t_e, t_f = symbols('t_a, t_b, t_c, t_d, t_e, t_f')
        a, v, s, t = symbols('a, v, s, t')
        

        prob_s = f"""
        A point travels along the $x$ axis with a velocity 
        whose projection $v_x$ is presented as a function of time 
        by the plot in the figure. 

        Assuming the coordinate of the 
        point $x=0$ at the moment $t=0$, draw the approximate time 
        dependence plots for the acceleration $w_x$, the $x$ 
        coordinate, and the distance covered $s$.


        see image::\images\physics\irodov_kinematics_q_1_18_a.png
        see image::\images\physics\irodov_kinematics_q_1_18_b.png
        see image::\images\physics\irodov_kinematics_q_1_18_c.png
        see image::\images\physics\irodov_kinematics_q_1_18_d.png

        """

        soln_stmts = []
        
        soln_stmt = f"""
        
        """
        soln_stmts.append(soln_stmt.strip())

        soln_stmt = f"""
        
        """
        soln_stmts.append(soln_stmt.strip())

        soln_stmt = f"""
        
        """
        soln_stmts.append(soln_stmt.strip())

        soln_s = '\n\n'.join(soln_stmts)

        answer_s = f"""
        
        """
        
        result = {
            'prob_s': prob_s.strip(),
            'soln_s': soln_s.strip(),
            'answer_s': answer_s.strip(),
            }
        return result
        pass

    def get_problem_irodov_1_18_copy(self, *args, **kwargs):
        """
        doc_style: xv_doc
        """
        
        a, b, c, d, e, f = symbols('a, b, c, d, e, f')
        v_a, v_b, v_c, v_d, v_e, v_f = symbols('v_a, v_b, v_c, v_d, v_e, v_f')
        t_a, t_b, t_c, t_d, t_e, t_f = symbols('t_a, t_b, t_c, t_d, t_e, t_f')
        a, v, s, t = symbols('a, v, s, t')
        

        prob_s = f"""
        get_problem_irodov_1_18
        1.18. A point travels along the $x$ axis with a velocity whose projection $v_x$ is presented as a function of time by the plot in Fig. 1.3. Assuming the coordinate of the point $x=0$ at the moment $t=0$, draw the approximate time dependence plots for the acceleration $w_x$, the $x$ coordinate, and the distance covered $s$.


        """.replace('\n', ' ')

        soln_stmts = []

        soln_stmt = f"""
        The acceleration from ${latex(a)}$ to ${latex(b)}$
        $\\displaystyle
        \\begin{{aligned}}
        \\Delta {latex(v)} &= {latex(a)} \\cdot \\Delta {latex(t)} \\\\
        {latex(v_b)} - {latex(v_a)} &= {latex(a)} \\cdot \\left({latex(t_b)} - {latex(t_a)}\\right) \\\\
        {latex(1)} - {latex(0)} &= {latex(a)} \\cdot \\left({latex(1)} - {latex(0)}\\right) \\\\
        {latex(a)} &= 1 \\\\
        \\end{{aligned}}
        $

        The distance travelled from ${latex(a)}$ to ${latex(b)}$
        $\\displaystyle
        \\begin{{aligned}}
        d{latex(s)} &= {latex(v)} \\cdot d{latex(t)} \\\\
        {latex(s)} &= \\int_{{0}}^{{1}} {latex(v)} \\cdot d{latex(t)} \\\\
        {latex(s)} &= \\int_{{0}}^{{1}} {latex(a)} {latex(t)} \\cdot d{latex(t)} \\\\
        \\end{{aligned}}
        $
        $\\displaystyle
        \\begin{{aligned}}
        {latex(s)} &= \\frac{{{latex(a)}}}{{{latex(2)}}} \\\\
        {latex(s)} &= \\frac{{{latex(1)}}}{{{latex(2)}}} \\\\
        \\end{{aligned}}
        $

        
        """
        soln_stmts.append(soln_stmt.strip())

        
        soln_stmt = f"""
        The acceleration from ${latex(b)}$ to ${latex(c)}$
        $\\displaystyle
        \\begin{{aligned}}
        \\Delta {latex(v)} &= {latex(a)} \\cdot \\Delta {latex(t)} \\\\
        {latex(v_c)} - {latex(v_b)} &= {latex(a)} \\cdot \\left({latex(t_c)} - {latex(t_b)}\\right) \\\\
        {latex(0)} - {latex(0)} &= {latex(a)} \\cdot \\left({latex(3)} - {latex(1)}\\right) \\\\
        {latex(a)} &= 1 \\\\
        \\end{{aligned}}
        $

        The distance travelled from ${latex(b)}$ to ${latex(c)}$
        $\\displaystyle
        \\begin{{aligned}}
        d{latex(s)} &= {latex(v)} \\cdot d{latex(t)} \\\\
        {latex(s)} &= \\int_{{1}}^{{3}} {latex(v)} \\cdot d{latex(t)} \\\\
        {latex(s)} &= \\int_{{1}}^{{3}} {latex(a)} {latex(t)} \\cdot d{latex(t)} \\\\
        {latex(s)} &= {latex(2)} \\\\
        \\end{{aligned}}
        $

        
        """
        soln_stmts.append(soln_stmt.strip())

        
        soln_stmt = f"""
        The acceleration from ${latex(c)}$ to ${latex(d)}$
        $\\displaystyle
        \\begin{{aligned}}
        \\Delta {latex(v)} &= {latex(a)} \\cdot \\Delta {latex(t)} \\\\
        {latex(v_d)} - {latex(v_c)} &= {latex(a)} \\cdot \\left({latex(t_d)} - {latex(t_c)}\\right) \\\\
        {latex(0)} - {latex(1)} &= {latex(a)} \\cdot \\left({latex(4)} - {latex(3)}\\right) \\\\
        {latex(a)} &= -1 \\\\
        \\end{{aligned}}
        $

        The distance travelled from ${latex(c)}$ to ${latex(d)}$
        $\\displaystyle
        \\begin{{aligned}}
        d{latex(s)} &= {latex(v)} \\cdot d{latex(t)} \\\\
        {latex(s)} &= \\int_{{3}}^{{4}} {latex(v)} \\cdot d{latex(t)} \\\\
        {latex(s)} &= \\int_{{3}}^{{4}} {latex(a)} {latex(t)} \\cdot d{latex(t)} \\\\
        {latex(s)} &= \\frac{{{latex(-1)}}}{{{latex(2)}}} \\\\
        \\end{{aligned}}
        $

        
        """
        soln_stmts.append(soln_stmt.strip())

        
        soln_stmt = f"""
        The acceleration from ${latex(d)}$ to ${latex(e)}$
        $\\displaystyle
        \\begin{{aligned}}
        \\Delta {latex(v)} &= {latex(a)} \\cdot \\Delta {latex(t)} \\\\
        {latex(v_e)} - {latex(v_d)} &= {latex(a)} \\cdot \\left({latex(t_e)} - {latex(t_d)}\\right) \\\\
        {latex(-2)} - {latex(0)} &= {latex(a)} \\cdot \\left({latex(6)} - {latex(4)}\\right) \\\\
        {latex(a)} &= -1 \\\\
        \\end{{aligned}}
        $

        The distance travelled from ${latex(d)}$ to ${latex(e)}$
        $\\displaystyle
        \\begin{{aligned}}
        d{latex(s)} &= {latex(v)} \\cdot d{latex(t)} \\\\
        {latex(s)} &= \\int_{{4}}^{{6}} {latex(v)} \\cdot d{latex(t)} \\\\
        {latex(s)} &= \\int_{{4}}^{{6}} {latex(a)} {latex(t)} \\cdot d{latex(t)} \\\\
        {latex(s)} &= {latex(-2)}\\\\
        \\end{{aligned}}
        $

        
        """
        soln_stmts.append(soln_stmt.strip())

        
        soln_stmt = f"""
        The acceleration from ${latex(e)}$ to ${latex(f)}$
        $\\displaystyle
        \\begin{{aligned}}
        \\Delta {latex(v)} &= {latex(a)} \\cdot \\Delta {latex(t)} \\\\
        {latex(v_f)} - {latex(v_e)} &= {latex(a)} \\cdot \\left({latex(t_f)} - {latex(t_e)}\\right) \\\\
        {latex(0)} - {latex(-2)} &= {latex(a)} \\cdot \\left({latex(7)} - {latex(6)}\\right) \\\\
        {latex(a)} &= 2 \\\\
        \\end{{aligned}}
        $

        The distance travelled from ${latex(a)}$ to ${latex(b)}$
        $\\displaystyle
        \\begin{{aligned}}
        d{latex(s)} &= {latex(v)} \\cdot d{latex(t)} \\\\
        {latex(s)} &= \\int_{{6}}^{{7}} {latex(v)} \\cdot d{latex(t)} \\\\
        {latex(s)} &= \\int_{{6}}^{{7}} {latex(a)} {latex(t)} \\cdot d{latex(t)} \\\\
        {latex(s)} &= {latex(1)} \\\\
        \\end{{aligned}}
        $

        
        """
        soln_stmts.append(soln_stmt.strip())

        
        soln_stmt = f"""
        The acceleration from ${latex(a)}$ to ${latex(b)}$
        $\\displaystyle
        \\begin{{aligned}}
        \\Delta {latex(v)} &= {latex(a)} \\cdot \\Delta {latex(t)} \\\\
        {latex(v_b)} - {latex(v_a)} &= {latex(a)} \\cdot \\left({latex(t_b)} - {latex(t_a)}\\right) \\\\
        {latex(1)} - {latex(0)} &= {latex(a)} \\cdot \\left({latex(1)} - {latex(0)}\\right) \\\\
        {latex(a)} &= 1 \\\\
        \\end{{aligned}}
        $

        The distance travelled from ${latex(a)}$ to ${latex(b)}$
        $\\displaystyle
        \\begin{{aligned}}
        d{latex(s)} &= {latex(v)} \\cdot d{latex(t)} \\\\
        {latex(s)} &= \\int_{{0}}^{{1}} {latex(v)} \\cdot d{latex(t)} \\\\
        {latex(s)} &= \\int_{{0}}^{{1}} {latex(a)} {latex(t)} \\cdot d{latex(t)} \\\\
        {latex(s)} &= {latex(1)}
        \\end{{aligned}}
        $

        
        """
        soln_stmts.append(soln_stmt.strip())

        
        
        soln_s = '\n\n'.join(soln_stmts)

        answer_s = f"""
        
        """
        
        result = {
            'prob_s': prob_s.strip(),
            'soln_s': soln_s.strip(),
            'answer_s': answer_s.strip(),
            }
        return result
        pass

    
    pass
#class KinematicsHelper:

    