Giter Site home page Giter Site logo

python-tutorials's Introduction

python-tutorials's People

Watchers

 avatar

python-tutorials's Issues

Functional specification of Rotation class

Rotation class

rot1 = Rotation.from_quat([0, 0, np.sin(np.pi/4), np.cos(np.pi/4)])
rot2 = Rotation.from_euler("ZYX", [0, np.pi/4, 0])
rot = rot1 * rot2

vector = np.array([1, 0, 0])
print(rot.apply(vector))

R = rot.as_matrix()
print(R @ vector)

Quaternion 곱셈

다음과 같이 Quaternion 인스턴스들을 곱하는 기능이 필요합니다.

q1 = Quaternion([1, 0, 0, 0])
q2 = Quaternion([1, 0, 0, 0])
q3 = q1 * q2
q4 = q2 * q1
print(q3)
print(q4)

참고

Python에는 operator를 활용하기 위한 __mul____rmul__ magic method 들이 존재합니다.

Quaternion 초기화 구현

다음과 같이 리스트 / Numpy array를 모두 인자로 받도록 Quaternion 인스턴스를 만드는게 어떨까요?

q = Quaternion([1, 0, 0, 0])
q = Quaternion(np.array([1, 0, 0, 0]))

Rotation class 내부함수들 as_ 구현

다음과 같이 Rotation 클래스 내부에 Rotation 인자 또는 Quaternion 인자를 input으로 받아서
각각 euler, quaternion, rotation matrix, rotation vector 형태로 output을 생성하는 as_ 함수들이 필요합니다.

from transform import Rotation as R

r = R.from_euler('zyx', [90, 45, 0], degrees=True)

r.as_euler()
r.as_quat()
r.as_rotmat()
r.as_rotvec()

Rotation class 내부함수들 from_ 구현

다음과 같이 Rotation 클래스 내부에 euler, quaternion, rotation matrix, rotation vector를 각각 input으로 받아서 Rotation 인자를 output으로 생성하는 from_ 함수들이 필요합니다.

from transform import Rotation as R
e = R.from_euler('zyx', [0, 45, 30], degrees=True)
q = R.from_quat([1, 0, 0, 0])
m = R.from_rotmat([[0, -1, 0], [1, 0, 0], [0, 0, 1]])
v = R.from_rotvec(np.pi/2 * np.array([0, 0, 1]))
v = R.from_rotvec(45 * np.array([0, 0, 1]), degrees=True)

[공지] Tutorial 03

목표

곱셈이 가능한 회전변환 클래스 만들기!

Reference: Scipy Rotation

상세 목표

작업 방식

작업 파일 및 폴더 구조

  • python-tutorials/tutorial-03/transform.py
    • Rotation 클래스가 정의되는 곳
  • python-tutorials/tutorial-03/main.py
    • 테스트 스크립트를 작성하는 곳
    • from transform import Rotation으로 Rotation 클래스를 불러온다.

애자일 프로세스

[프로젝트 보드]

  1. 브레인스토밍을 통해 프로젝트 보드의 ToDo에 아이템들을 만든다.
  2. 각자 ToDo 아이템들 중 급해 보이는 것(혹은 하고 싶은 것)을 선점해서 본인을 할당한다 (Assignee)
  3. 당장 작업중인 아이템은 In Progress로 옮긴다.
  4. 끝나면 Done으로 보낸다.

만약 간단히 해결이 안되고 도움이나 토의/토론이 필요하면 아이템을 이슈로 변환할 수 있다!.
이때, 레포를 seong-hun/python-tutorial로 설정해야 한다.

협업 방식

Git Flow

  1. 우선 이 레포를 Fork 한다.
  2. Fork 된 레포(본인 계정 밑에 생성됨) 클론!
  3. 로컬 레포(본인 컴퓨터)에서 작업한다.
    • 우선 로컬 브랜치를 적절한 이름으로 만든다 (예: iss31 또는 create-quat-mul)
      git checkout -b [branch_name]

      실제로는 branch_name 주위에 대괄호가 없음에 유의!!

    • 작업 후 add/commit!
      git add [file_name]
      git commit -m "[commit_message]"
  4. (중요!) 푸쉬하기 전에 upstream/main으로 머지 가능한지 테스트한다!!
    • upstream에서 최신 정보를 받는다.
      git checkout main
      git pull upstream main
      git merge --squash [branch_name]
    • 충돌이 난다면 충돌을 적절히 해결할 때까지 로컬 브랜치를 수정한다.
      • 이때, main 브랜치가 아니라 [branch_name] 브랜치에 새로운 커밋으로 수정한다.
      • 최대한 rebase, reset 등을 피하고 merge 등을 이용한다. (force push 방지!)
  5. 로컬 브랜치를 본인 Fork 레포에 푸쉬 한다.
    git checkout [branch_name]
    git push -u origin [branch_name]
  6. 본인 Fork 레포에 가보면 seong-hun/python-tutorial에 풀리퀘를 보낼 수 있는 옵션이 있다!

풀리퀘 (Pull requests) 작성법

## 구현한 기능

(상세한 설명)

## 작동 테스트

(작동 테스트 결과 - 화면 캡쳐 / 결과 프롬프트 복붙)

풀리퀘 관리

Squash and merge를 굳이 사용하지 않고 다양하게 시도해봐도 좋다!

Quaternion representation 구현

아래와 같이 쿼터니언을 프린트 했을 때 어떤 쿼터니언인지 잘 보이면 좋지 않을까요??

print(Quaternion([1, 2, 3, 4]))

참고

Python __repr__ method

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.