'''
Created on 12-Jul-2021

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

from xv.km.kelements import KImgElement
from xv.util import locatePath


from xv.util import UtilClass


class WaveHelper(UtilClass):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        pass
    
    def eq_for_wave_in_a_stretched_string(self):
   
        image_path = "resources/images/wave-equation-in-a-string.png"
        rootFolder = pathlib.Path(__file__).parent.absolute()
        kel = KImgElement(image_path, rootFolder = rootFolder, verbose = self.verbose)
        img_str = kel.get_img_element() 
        
        problem_s = f"""
        https://www.animations.physics.unsw.edu.au/jw/wave_equation_speed.htm
        """
        
        soln_s = rf"""
        $\mu$ = mass per unit length 
        $T$ = tension in string, also $T >>$ the weight of the string 
        
        Let the string has its equilibrium position is along the $\mathrm{{x}}$ axis. 
        
        This diagram shows a short section of the string, stretched in the $\mathrm{{x}}$ direction, and the forces acting on it. Our analysis only applies for small deformations, for which the string is a linear medium, and we neglect the gravitational force on the string (which in any case is constant).
        
        {img_str}
        
        One consequence of this restriction to small deformations is that the angle $\theta$ between the string and the $\mathrm{{x}}$ direction is much smaller than 1 , so $\sin \theta \cong \theta$ and $\cos \theta \cong 1$. (On our diagram, however, the deformation has been exaggerated for clarity.) It also follows that the length of the segment shown is $\mathrm{{dx}}$.
        Let's apply Newton's second law in the vertical y direction:
        $
        \mathrm{{F}}_{{\mathrm{{y}}}}=\mathrm{{ma}}_{{\mathrm{{y}}}} \text {{. }}
        $
        The sum of forces in the $y$ direction is
        $
        \mathrm{{F}}_{{\mathrm{{y}}}}=T \sin \theta_{{2}}-T \sin \theta_{{1}} \text {{. }}
        $
        
                
        """
        
        answer_s = f"""
        """
        
        result = {
            
            'problem_s': problem_s.strip(),
            'soln_s': soln_s.strip(),
            'answer_s': answer_s.strip(),
            
            }
        
        return result
        pass

    def _log_DELETED(self, sOut, to_print = None):
        if to_print is None:
            to_print = self.verbose
            
        if to_print:
            print(sOut)
    

    pass
#class WaveHelper:

    