Giter Club home page Giter Club logo

modu-p5-project-vector00's Introduction

P5 Vector (29. JUNE. 2017 in Modulab)

Vector의 특성에 대해서 알아보고 적용해본 예제입니다.
마우스를 따라 일정한 속도로 움직이는 원을 그립니다.

Vector의 사전적 의미

벡터(vector)는 크기 만으로 나타낼 수 있는 스칼라(scalar)와 달리 방향과 크기를 사용하여 나타낼 수 있다. 일상적으로 사용하는 벡터는 유향선분(방향이 있는 선분 즉, 화살표)를 써서 표현할 수 있다

Vector의 특징

vector의 표현

  • 2차원에서의 Vector는 x좌표와 y좌표를 표현할 수 있다.
/* Pseudocode */
var vector = { a : ?, b : ?} //x는 x좌표 y는 y좌표
vector.a //실제 x좌표
vector.b //실제 y좌표
  • 2차원에서의 Vector는 각도(Radian)와 거리(Distance)를 표현할 수 있다.
/* Pseudocode */
var vector = { a : ?, b : ?} //a는 각도(Radian), b는 거리(Distance)
vector.b * cos(vector.a * PI) //실제 x좌표
vector.b * sin(vector.a * PI) //실제 y좌표
  • 3차원에서의 Vector는 x, y, z좌표를 표현할 수 있다.
  • 3차원에서의 Vector는 xy평면의 각도, yz평면의 각도, 거리를 표현할 수 있다.

vector의 연산

  • normalization(정규화) : vector를 x좌표와 y좌표로 사용하고 있을때 크기가 1인 Vector로 바꾸고 싶을 때 주로 사용한다.
    주의해야할 점은 normalization을 하면 normal vector가 아니라 unit vector가 된다
/* Pseudocode */
var vector = { x : ?, y : ? }
var length = sqrt(vector.x * vector.x + vector.y * vector.y)
vector.x / length // Unit Vector의 x
vector.y / length // Unit Vector의 y
/* Pseudocode */
var vector = { rad : ?, len : ? }
cos(vector.rad * PI) // Unit Vector의 x
sin(vector.rad * PI) // Unit Vector의 y
  • dot product(내적 연산) : 두 백터의 내적 연산은 한 Vector A를 다른 Vector B에 투영시켰을 때의 크기를 계산한다.
  • outer product(외적 연산) : 두 백터의 외적 연산은 두 백터와 모두 수직한 백터 C를 계산한다. 3차원 공간에서 사용된다.

실행

네트워크가 되는 환경에서 index.html을 실행합니다.

환경

포함되어있는 예제는 P5js를 사용하여 제작되었습니다.

License

Copyright (c) 2017 Donghyeon Kim ([email protected])

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

modu-p5-project-vector00's People

Contributors

dhygns avatar

Watchers

James Cloos avatar  avatar

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.