
"""simple docstring"""







from typing import Dict, List, Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import center_crop, normalize, rescale, resize, to_channel_dimension_format
from ...image_utils import (
    IMAGENET_DEFAULT_MEAN,
    IMAGENET_DEFAULT_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    get_image_size,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


if is_vision_available():
       import PIL


lowercase_						    =					logging.get_logger(__name__)



class 		UpperCAmelCase_	(lowerCamelCase_						):
 """simple docstring"""




 UpperCamelCase_						:     Optional[Any]				   =    ["""pixel_values"""]




 def __init__( self       : List[Any]     ,   a_       : bool = True     ,   a_       : Dict[str, int] = None     ,   a_       : bool = True     ,   a_       : Dict[str, int] = None     ,   a_       : PILImageResampling = PILImageResampling.BICUBIC     ,   a_       : bool = True     ,   a_       : Union[int, float] = 1 / 2_55     ,   a_       : bool = True     ,   a_       : Optional[Union[float, List[float]]] = None     ,   a_       : Optional[Union[float, List[float]]] = None     ,   **a_       : int     ,   )->					None:



      """simple docstring"""

      super().__init__(**a_ )
      UpperCAmelCase_						:    int    					=  crop_size if crop_size is not None else {"""height""": 2_56, """width""": 2_56}
      UpperCAmelCase_						:    Any    					=  get_size_dict(a_     ,   param_name="""crop_size""" )
      UpperCAmelCase_						:    Dict    					=  size if size is not None else {"""height""": 2_24, """width""": 2_24}
      UpperCAmelCase_						:    int    					=  get_size_dict(a_ )

      UpperCAmelCase_						:    str    					=  do_center_crop
      UpperCAmelCase_						:    Optional[Any]    					=  crop_size
      UpperCAmelCase_						:    Union[str, Any]    					=  do_resize
      UpperCAmelCase_						:    List[Any]    					=  size
      UpperCAmelCase_						:    Tuple    					=  resample
      UpperCAmelCase_						:    Optional[Any]    					=  do_rescale
      UpperCAmelCase_						:    Tuple    					=  rescale_factor
      UpperCAmelCase_						:    int    					=  do_normalize
      UpperCAmelCase_						:    List[str]    					=  image_mean if image_mean is not None else IMAGENET_DEFAULT_MEAN
      UpperCAmelCase_						:    Union[str, Any]    					=  image_std if image_std is not None else IMAGENET_DEFAULT_STD




 def   a      ( self       : Dict     ,   a_       : np.ndarray     ,   a_       : Dict[str, int]     ,   a_       : Optional[int] = None     ,   a_       : Optional[Union[str, ChannelDimension]] = None     ,   **a_       : Dict     ,   )->					np.ndarray:



      """simple docstring"""

      UpperCAmelCase_						:    List[Any]    					=  self.size if size is None else size
      UpperCAmelCase_						:    Union[str, Any]    					=  get_size_dict(a_ )
      UpperCAmelCase_						:    List[str]    					=  get_size_dict(a_     ,   param_name="""crop_size""" )

      UpperCAmelCase_					,UpperCAmelCase_						:    List[str]    					=  get_image_size(a_ )
      UpperCAmelCase_						:    Union[str, Any]    					=  min(a_     ,   a_ )
      UpperCAmelCase_						:    List[Any]    					=  (size["""height"""] / crop_size["""height"""]) * min_dim
      UpperCAmelCase_						:    Optional[int]    					=  (size["""width"""] / crop_size["""width"""]) * min_dim
      return center_crop(a_     ,   size=(cropped_height, cropped_width)     ,   data_format=a_     ,   **a_ )




 def   a      ( self       : List[str]     ,   a_       : np.ndarray     ,   a_       : Dict[str, int]     ,   a_       : PILImageResampling = PIL.Image.BICUBIC     ,   a_       : Optional[Union[str, ChannelDimension]] = None     ,   **a_       : Optional[int]     ,   )->					np.ndarray:



      """simple docstring"""

      UpperCAmelCase_						:    Optional[Any]    					=  get_size_dict(a_ )
      if "height" not in size or "width" not in size:
           raise ValueError(f'''The size dictionary must contain the keys \'height\' and \'width\'. Got {size.keys()}''' )
      return resize(
          a_     ,   size=(size["""height"""], size["""width"""])     ,   resample=a_     ,   data_format=a_     ,   **a_ )




 def   a      ( self       : Dict     ,   a_       : np.ndarray     ,   a_       : Union[int, float]     ,   a_       : Optional[Union[str, ChannelDimension]] = None     ,   **a_       : List[Any]     ,   )->					Union[str, Any]:



      """simple docstring"""

      return rescale(a_     ,   scale=a_     ,   data_format=a_     ,   **a_ )




 def   a      ( self       : Dict     ,   a_       : np.ndarray     ,   a_       : Union[float, List[float]]     ,   a_       : Union[float, List[float]]     ,   a_       : Optional[Union[str, ChannelDimension]] = None     ,   **a_       : Any     ,   )->					np.ndarray:



      """simple docstring"""

      return normalize(a_     ,   mean=a_     ,   std=a_     ,   data_format=a_     ,   **a_ )






 def   a      ( self       : List[str]     ,   a_       : ImageInput     ,   a_       : Optional[bool] = None     ,   a_       : Optional[Dict[str, int]] = None     ,   a_       : Optional[bool] = None     ,   a_       : Optional[Dict[str, int]] = None     ,   a_       : PILImageResampling = None     ,   a_       : Optional[bool] = None     ,   a_       : Optional[float] = None     ,   a_       : Optional[bool] = None     ,   a_       : Optional[Union[float, List[float]]] = None     ,   a_       : Optional[Union[float, List[float]]] = None     ,   a_       : Optional[Union[str, TensorType]] = None     ,   a_       : ChannelDimension = ChannelDimension.FIRST     ,   **a_       : int     ,   )->					PIL.Image.Image:



      """simple docstring"""

      UpperCAmelCase_						:    Tuple    					=  do_center_crop if do_center_crop is not None else self.do_center_crop
      UpperCAmelCase_						:    Dict    					=  crop_size if crop_size is not None else self.crop_size
      UpperCAmelCase_						:    List[str]    					=  get_size_dict(a_     ,   param_name="""crop_size""" )
      UpperCAmelCase_						:    List[Any]    					=  do_resize if do_resize is not None else self.do_resize
      UpperCAmelCase_						:    List[str]    					=  size if size is not None else self.size
      UpperCAmelCase_						:    Union[str, Any]    					=  get_size_dict(a_ )
      UpperCAmelCase_						:    int    					=  resample if resample is not None else self.resample
      UpperCAmelCase_						:    Dict    					=  do_rescale if do_rescale is not None else self.do_rescale
      UpperCAmelCase_						:    Optional[Any]    					=  rescale_factor if rescale_factor is not None else self.rescale_factor
      UpperCAmelCase_						:    List[Any]    					=  do_normalize if do_normalize is not None else self.do_normalize
      UpperCAmelCase_						:    Optional[int]    					=  image_mean if image_mean is not None else self.image_mean
      UpperCAmelCase_						:    Any    					=  image_std if image_std is not None else self.image_std

      UpperCAmelCase_						:    Optional[int]    					=  make_list_of_images(a_ )

      if not valid_images(a_ ):
           raise ValueError(
               """Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, """
               """torch.Tensor, tf.Tensor or jax.ndarray.""" )

      if do_center_crop and crop_size is None:
           raise ValueError("""If `do_center_crop` is set to `True`, `crop_size` must be provided.""" )

      if do_resize and size is None:
           raise ValueError("""Size must be specified if do_resize is True.""" )

      if do_rescale and rescale_factor is None:
           raise ValueError("""Rescale factor must be specified if do_rescale is True.""" )

      if do_normalize and (image_mean is None or image_std is None):
           raise ValueError("""Image mean and image standard deviation must be specified if do_normalize is True.""" )

      # All transformations expect numpy arrays.
      UpperCAmelCase_						:    str    					=  [to_numpy_array(a_ ) for image in images]

      if do_center_crop:
           UpperCAmelCase_						:    List[str]    					=  [self.center_crop(a_     ,   a_     ,   size=a_ ) for image in images]

      if do_resize:
           UpperCAmelCase_						:    Any    					=  [self.resize(image=a_     ,   size=a_     ,   resample=a_ ) for image in images]

      if do_rescale:
           UpperCAmelCase_						:    str    					=  [self.rescale(image=a_     ,   scale=a_ ) for image in images]

      if do_normalize:
           UpperCAmelCase_						:    List[Any]    					=  [self.normalize(image=a_     ,   mean=a_     ,   std=a_ ) for image in images]

      UpperCAmelCase_						:    Optional[int]    					=  [to_channel_dimension_format(a_     ,   a_ ) for image in images]

      UpperCAmelCase_						:    Dict    					=  {"""pixel_values""": images}
      return BatchFeature(data=a_     ,   tensor_type=a_ )



"""simple docstring"""







from math import radians as angle_to_radians
from math import sin

# Acceleration Constant on Earth (unit m/s^2)
lowercase_						    =					9.8_0665




def 			A_			(					lowercase						, lowercase      )     ->							None:


     """simple docstring"""







     if not isinstance(lowercase						, (int, float)      ):
          raise TypeError("""Invalid velocity. Should be a positive number."""      )

     if not isinstance(lowercase						, (int, float)      ):
          raise TypeError("""Invalid angle. Range is 1-90 degrees."""      )

     # Ensure valid angle
     if angle > 90 or angle < 1:
          raise ValueError("""Invalid angle. Range is 1-90 degrees."""      )

     # Ensure valid velocity
     if init_velocity < 0:
          raise ValueError("""Invalid velocity. Should be a positive number."""      )




def 			A_			(					lowercase						, lowercase      )     ->							float:


     """simple docstring"""







     check_args(lowercase						, lowercase      )
     UpperCAmelCase_						:    Any    					=  angle_to_radians(2 * angle      )
     return round(init_velocity**2 * sin(lowercase      ) / g						, 2      )




def 			A_			(					lowercase						, lowercase      )     ->							float:


     """simple docstring"""







     check_args(lowercase						, lowercase      )
     UpperCAmelCase_						:    Union[str, Any]    					=  angle_to_radians(lowercase      )
     return round(init_velocity**2 * sin(lowercase      ) ** 2 / (2 * g)						, 2      )




def 			A_			(					lowercase						, lowercase      )     ->							float:


     """simple docstring"""







     check_args(lowercase						, lowercase      )
     UpperCAmelCase_						:    Optional[int]    					=  angle_to_radians(lowercase      )
     return round(2 * init_velocity * sin(lowercase      ) / g						, 2      )




def 			A_			(					)     ->							None:


     """simple docstring"""







     UpperCAmelCase_					,UpperCAmelCase_						:    Optional[int]    					=  25, 20
     assert horizontal_distance(lowercase						, lowercase      ) == 40.97
     assert max_height(lowercase						, lowercase      ) == 3.73
     assert total_time(lowercase						, lowercase      ) == 1.74


if __name__ == "__main__":
       from doctest import testmod

       testmod()

       # Get input from user
       lowercase_						    =					float(input("Initial Velocity: ").strip())

       # Get input from user
       lowercase_						    =					float(input("angle: ").strip())

       # Print results
       print()
       print("Results: ")
       print(f"""Horizontal Distance: {horizontal_distance(init_vel, angle)!s} [m]""")
       print(f"""Maximum Height: {max_height(init_vel, angle)!s} [m]""")
       print(f"""Total Time: {total_time(init_vel, angle)!s} [s]""")

