Learn Encapsulation by Building a Projectile Trajectory Calculator - Step 6

Tell us what’s happening:

am i missing something here? i don’t know how to do the v squared power of two also i keep getting Projectile(12, 12, 12) as error For Projectile(12, 12, 12) , given the 4 $x$ coordinates of 0, 1, 2 and 3, the y coordinate should be approximately 12, 12.18, 12.28, 12.32. what does this mean?

Your code so far

import math

GRAVITATIONAL_ACCELERATION = 9.81
PROJECTILE = "∙"
x_axis_tick = "T"
y_axis_tick = "⊣"

class Projectile:
    __slots__ = ('__speed', '__height', '__angle')

    def __init__(self, speed, height, angle):
        self.__speed = speed
        self.__height = height
        self.__angle = math.radians(angle)
        
    def __str__(self):
        return f'''
Projectile details:
speed: {self.__speed} m/s
height: {self.__height} m
angle: {round(math.degrees(self.__angle))}°
displacement: {round(self.__calculate_displacement(), 1)} m
'''

    def __calculate_displacement(self):
        horizontal_component = self.__speed * math.cos(self.__angle)
        vertical_component = self.__speed * math.sin(self.__angle)
        squared_component = vertical_component**2
        gh_component = 2 * GRAVITATIONAL_ACCELERATION * self.__height
        sqrt_component = math.sqrt(squared_component + gh_component)
        
        return horizontal_component * (vertical_component + sqrt_component) / GRAVITATIONAL_ACCELERATION
    def __calculate_y_coordinate(self,x):
        vertical_component = (self.__speed * math.sin(self.__angle))*0+ x * math.tan(self.__angle) - GRAVITATIONAL_ACCELERATION*x**2/2*self.__speed**2 * math.cos(self.__angle) 

# User Editable Region

    

# User Editable Region


ball = Projectile(10, 3, 45)
print(ball)
ball._Projectile__calculate_y_coordinate(1)   

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36

Challenge Information:

Learn Encapsulation by Building a Projectile Trajectory Calculator - Step 6

as you are missing a return statement in the function, you are not going to get any valuable feedback from the tests

which part of the formula are you talking about? I don’t understand

it means that for a Projectile with starting speed of 12 m/s, starting height of 12 m, and starting angle of 12 °, for an x value of 0m, 1m, 2m, 3m, the y value is 12m, 12.18m, 12.28m and 12.32m

im talking about the 2 times v squared 0 in the denominator

v_0 is the starting value of speed, which you have. You need to square it, which is explained in the instructions how to do.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.