Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions TP2/imu_analysis/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@
Module pour le traitement des mesures
*************************************
"""
def calculate_moving_average(data: list[float], interval: int):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stp ajoute une ligne vide avant la fonction

moyenne_glissante = 0
n = 4
for i in range(n,interval+n):
moyenne_glissante = moyenne_glissante + list[n-i]
moyenne_glissante = moyenne_glissante / interval
return moyenne_glissante
7 changes: 5 additions & 2 deletions TP3/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@


class Person:
def __init__(self, first_name: str, last_name: str, age: int) -> None:
def __init__(self, first_name: str, last_name: str, age: int, email:str="non renseigné", phone:str="non renseigné") -> None:
self.first_name = first_name.capitalize()
self.last_name = last_name.upper()
self.age = age
self.email = email
self.phone = phone
def __str__(self) -> str:
return f"{self.first_name} {self.last_name}"


def main():
Expand All @@ -14,6 +18,5 @@ def main():
print(f"Last name: {john.last_name}")
print(f"Age: {john.age}")


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion TP3/person_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def main():
print(f"Is Bob of age: {bob.is_of_age()}")

print("Change the age of majority to 32")
# TODO
Person.AGE_MAJORITY = 32

print(f"Is John of age: {john.is_of_age()}")
print(f"Is Bob of age: {bob.is_of_age()}")
Expand Down
33 changes: 31 additions & 2 deletions TP3/vectors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
"""Manipulation of 2D-vectors."""

from __future__ import annotations
import numpy as np
from typing import Self

class Point:
def __init__(self, x: float, y: float)-> None:
self.x = x
self.y = y

def str(self) -> float:
return f"{self.x} {self.y}"

class Vector:
def __init__(self, begin: Point, end: Point)-> None:
self.beginpoint = begin
self.endpoint = end

self.x = end.x - begin.x
self.y = end.y - begin.y

def norm(self) -> float:
"""retourne la norme d'un vecteur"""
return np.squrt (self.x **2 + self.y **2)

def dotprod(self, other: Vector) -> float:
return self.x * other.x + self.y * other.y

def add(self, other: Vector) -> Vector:
return Vector(Point(self.x, self.y),Point(self.x + other.x, self.y + other.y))



def main():
Expand All @@ -19,8 +48,8 @@ def main():


def main_2():
v = Vector(1, 2)
v2 = Vector(1, 0)
v = Vector(Point(0,0),Point(1,2))
v2 = Vector(Point(0,0),Point(1,0))
print(v.dot_prod(v2))
print(v2.dot_prod(v))

Expand Down