>
Game Develop/Physics

2D 물리엔진을 만드는 방법 4편 번역

http://gamedevelopment.tutsplus.com/tutorials/how-to-create-a-custom-2d-physics-engine-oriented-rigid-bodies--gamedev-8032


위 링크는 원본 글


이제 마지막이다... ㅠ

항상 쓰지만 번역기보다 못한 발번역이니 주의할것...

중간부분이 모르는 개념이라서 그런지 번역품질이 매우 안좋음...


여기서 모델 공간 이런걸 말하면 로컬 공간으로 보면됨

---------------------------------------------------------------------------------------------------

So far, we've covered impulse resolutionthe core architecture, and friction. In this, the final tutorial in this series, we'll go over a very interesting topic: orientation.

In this article we will discuss the following topics:

  • Rotation math
  • Oriented shapes
  • Collision detection
  • Collision resolution

I highly recommended reading up on the previous three articles in the series before attempting to tackle this one. Much of the key information in the previous articles are prerequisites to rest of this article. <iframe src="http://tpc.googlesyndication.com/safeframe/1-0-2/html/container.html" style="display: none; visibility: hidden;"></iframe>



I've created a small sample engine in C++, and I recommend that you browse and refer to the source code throughout the reading of this article, as many practical implementation details could not fit into the article itself.

(나는 C++로 작은 샘플 엔진을 만들었고 네가 살펴보고 이 글을 읽는 내내 소스코드를 내내 봤으면 좋겠고 많은 실제 코드는 이 글과 맞지 않을 수도 있다)

 

This GitHub repo contains the sample engine itself, along with a Visual Studio 2010 project. GitHub allows you to view the source without needing to download the source itself, for convenience.

(비주얼 스튜디오 2010으로 만든 프로젝트가 GitHub에 올라왔다는 이야기)



The math involving rotations in 2D is quite simple, although a mastery of the subject will be required to create anything of value in a physics engine. Newton's second law states:

(2D에서의 회전과 관련된 수학은 꽤 간단하다. 하지만 물리엔진에서 어떤 값이든지 만들기 위해서 이 주제를 숙달이 필요하다. 뉴턴의 2번째 법칙:)

Equation 1

 F%3Dma%20


There is a similar equation that relates specifically angular force and angular acceleration. However, before these equations can be shown, a quick description of the cross product in 2D is required.

(특별한 각의 힘과 각속도와 비슷한 식이다. 하지만 이 식들은 2D에서 요구되는 외적을 먼저 보여줄 것이다.)

The cross product in 3D is a well known operation. However, the cross product in 2D can be quite confusing, as there isn't really a solid geometric interpretation.

(외적은 3D에서 잘 알려진 식이다. 하지만 2D에서는 꽤 혼란스럽고 기하학적 해석이 없다.)

The 2D cross product, unlike the 3D version, does not return a vector but a scalar. This scalar value actually represents the magnitude of the orthogonal vector along the z-axis, if the cross product were to actually be performed in 3D. In a way, the 2D cross product is just a simplified version of the 3D cross product, as it is an extension of 3D vector math.

(2D 외적은 3D버전같지 않고 벡터값 대신 스칼라 값을 준다. 이 스칼라 값은 3D에서의 외적이였다면 실제로 z-축을 따라 직교벡터의 크기를 나타낸다. 어느정도 2D 외적은 3D 벡터의 확장 및 축소에 따른 3D 외적의 단순화 버전이다.)

If this is confusing, do not worry: a thorough understanding of the 2D cross product is not all that necessary. Just know exactly how to perform the operation, and know that the order of operations is important: a X b is not the same as b X a . This article will make heavy use of the cross product in order to transform angular velocity into linear velocity.

(만약 혼란 스럽다면 걱정하지마라: 2D 외적을 꼭 이해할 필요는 없다. 단지 어떻게 진행하는 지 정확히 알고 순서를 아는 것이 중요하다. a X b 는 b X a와 같지 않다. 이 글에서는 각속도를 선형 속도로 변환하는데 외적을 많이 사용할 것이다.)

Knowing how to perform the cross product in 2D is very important, however. Two vectors can be crossed, a scalar can be crossed with a vector, and a vector can be crossed with a scalar. Here are the operations:

(2D 외적이 어떻게 진행되는지 아는 것이 중요하지만 2개의 벡터가 수직일때 스칼라가 벡터와 수직이 될 수 있고 벡터도 스칼라와 수직이 될 수 있다. 여기 작업이 있다:)


As we all should know from the previous articles, this equation represents a relationship between the force acting upon a body with that body's mass and acceleration. There is an analog for rotation:

(이 식은 몸체와 몸체의 질량과 가속 사이에 작용하는 힘을 나타내는 것이라고 함)

Equation 2

T%3Dr%5Ctimes%20w%20


T stands for torque. Torque is rotation force.

(T는 토크를 나타낸다. 토크는 회전 힘이다.


r is a vector from the center of mass (COM) to a particular point on an object. r can be thought of as referring to a "radius" from COM to a point. Every single unique point on an object will require a different r value to be represented in Equation 2.

(r은 질량 중심으로부터 오브젝트의 특정한 점까지의 벡터이다. r은 질량 줌심으로부터의 반지름을 나타낼 수 있다. 물체에서의 특별한 한 점은 다른 r 값을 요구하는 것을 식2에서 나타낸다.)


w is called "omega", and refers to rotational velocity. This relationship will be used to integrate angular velocity of a rigid body.

(w는 오메가를 뜻하고 회적 속도를 나타낸다. 이 관계는 강체에서의 각속도를 통합하는데 사용한다.)


It is important to understand that linear velocity is the velocity of the COM of a rigid body. In the previous article, all objects had no rotational components, so the linear velocity of the COM was the same velocity for all points on a body. When orientation is introduced, points farther away from the COM rotate faster than those near the COM. This means we need a new equation to find the velocity of a point on a body, since bodies can now spin and translate at the same time.

(강체의 질량 중심인 선형 속도를 이해하는 것은 중요하다. 이전 글에서는 모든 물체들은 회전 컴포넌트들을 가지고 있지 않았었고 그래서 중심 질량의 선형속도는 몸통위의 모든 점들까지의 속도와 같았다. 방향이 소개될 때 점이 질량 중심 가까이 있는 것보다 멀리 있는 것이 더 회전이 빠르다. 몸통들이 이제 돌고 이동을 동시에 할 수 있기 때문에 이것은 우리가 몸체위의 점의 속도를 새로운 식을 찾아야할 필요가 있다는 것을 의미한다


Use the following equation to understand the relationship between a point on a body and the velocity of that point:

(이 식으로 몸통위의 점과 그 점의 속도 사이의 관계를 이해하라)

Equation 3

w%3Dr%5Ctimes%20v%20


v represents linear velocity. To transform linear velocity into angular velocity, cross the r radius with v.

(v는 선형 속도를 나타낸다. 선형속도를 각속도로 변환을 위해 r과 v를 직교한다.)

Similarly, we can rearrange Equation 3 to form another version:

(마찬가지로 우리는 다른버전으로부터 식3을 손볼 수있다)


Equation 4

v%3Dw%5Ctimes%20r%20


The equations from the last section are quite powerful only if rigid bodies have uniform density. Non-uniform density makes the math involved in calculating anything required the rotation and behavior of a rigid body much too complicated. Furthermore, if the point representing a rigid body is not at the COM, then the calculations regarding r are going to be entirely wonky.

(일정한 밀도를 가진 강체일때 마지막 섹션의 식은 꽤 강력하다. 일정하지 않은 밀도는 어떤것을 계산하든 회전과 강체의 행동을 너무 많이 요구한다. 더나아가 만약 강체를 나타내는 점이 질량 중심에 없다면 r에 대한 계산은 전체적으로 불안정할 것이다.)


In two dimensions an object rotates about the imaginary z-axis. This rotation can be quite difficult depending on how much mass an object has, and how far away from the COM the object's mass is. A circle with mass equal to a long thin rod will be easier to rotate than the rod. This "difficulty to rotate" factor can be thought of as the moment of inertia of an object.

(2차원에서의 물체의 회전은 가상의 z축으로 회전한다. 이 회전은 물체가 얼마나 질량을 가지고 있고 물체의 질량이 질량의 중심으로부터 멀리 떨어져있는지에 따라 꽤 어려울 수도 있다. 원과 질량이 있는 긴 막대와 같은 것은 막대 회전보다 회전이 쉬울것이다. 이 "어려운 회전"은 사실 물체의 관성의 시점이라고 할 수 있다.)

In a sense, inertia is the rotational mass of an object. The more inertia something has, the harder it is to get it spinning.

(어떤 의미에서 관성은 물체의 회전의 질량(크기)이다. 관성을 더 가지면 더 세게 회전한다.) 

Knowing this, one could store the inertia of an object within the body as the same format as mass. It would wise to also store the inverse of this inertia value, being careful not to perform a division by zero. Please see the previous articles in this series for more information on mass and inverse mass.

(이것을 아는 것은 물체의 관성을 몸통안에 질량과 같은 포멧으로 저장 할 수 있다는 것다. 관성 값을 역으로 저장하는 것이 지혜롭겠지만 0으로 나누지 않도록 주의해라. 이전 글에서 질량과 반전된 질량에 대해 참고하라.)

Each rigid body will require a few more fields to store rotational information. Here's a quick example of a structure to hold some additional data:

(각각의 강체는 몇가지의 회전 정보 저장을 요구한다. 여기 몇가지 추가된 데이터를 가진 구조체의 간단한 예제가 있다.)



Integrating the angular velocity and orientation of a body are very similar to the integration of velocity and acceleration. Here is a quick code sample to show how it's done (note: details about integration were covered in a previous article):

(각 속도와 몸통의 방향 통합은 속도와 가속도의 통합과 매우 비슷하다. 여기 간단한 코드 샘플을 통해 어떻게 하는지 보여주겠다.(자세한 통합 이야기는 이전 글 참고))



With the small amount of information presented so far, you should be able to start rotating various things on the screen without any trouble. With just a few lines of code, something rather impressive can be constructed, perhaps by tossing a shape into the air while it rotates about the COM as gravity pulls it downward to form an arced path of travel.

(지금까지 작은 양의 정보가 제공되었지만 너는 화면에서 다양한 회전을 어떤 문제도 없이 시작할 수 있다. 단지 몇 줄의 코드와 함께 뭔가 꽤 인상적으로 만들어질 수 있고 어쩌면 모형을 공중으로 쳐냄으로 질량의 중심에서 회전하는 동안 중력이 밑으로 당기고 아치형 경로로 움직인다.)


Mat22


Orientation should be stored as a single radian value, as seen above, though often times the use of a small rotation matrix can be a much better choice for certain shapes.

(회전은 하나의 라디안 값에 저장되어야 하고 위와 같이 보통 작은 행렬을 사용하는 것이 어떤 모형들에서는 더 나은 선택이다.)


A great example is the Oriented Bounding Box (OBB). The OBB consists of a width and height extent, both of which can be represented by vectors. These two extent vectors can then be rotated by a two-by-two rotation matrix to represent the axes of an OBB.

(이것은 OBB의 좋은 예제이다. OBB는 너비와 높이 범위로 구성 되어있다. 이 2개의 범위 벡터는 OBB의 축을 나타내는 2x2 회전 행렬에 의해 회전 할 수 있다.)


I  suggest the creation of a Mat22 matrix class to be added to whatever math library you are using. I myself use a small custom math library which is packaged in the open source demo. Here is an example of what such an object may look like:

(나는 Mat22 행렬 클래스를 만들어 네가 수학 라이브러리를 언제든지 사용할때 추가하는 것을 제안한다. 나 자신은 오픈 소스 데모에서 작은 커스텀 수학 라이브러리를 사용한다. 여기 예제를 봐라:)



Some useful operations include: construction from angle, construction from column vectors, transpose, multiply with Vec2, multiply with another Mat22, absolute value.

(몇가지 유용한 기능들이 포함되어있다 : 각도로부터의 구성, 열벡터로부터의 구성, 옮김, Vec2의 곱, 다른 Mat22와의 곱, 절대값)

The last useful function is to be able to retrieve either the x or y column from a vector. The column function would look something like:

(마지막으로 유용한 기능은 벡터로부터 x와 y의 열을 구할 수 있다. 그 열 기능은 이렇게 보일 것이다:)



This technique is useful for retrieving a unit vector along the an axis of rotation, either the x or y axis. Additionally, a two-by-two matrix can be constructed from two orthogonal unit vectors, as each vector can be directly inserted into the rows. Although this construction method is a bit uncommon for 2D physics engines, it can still be very useful to understand how rotations and matrices work in general.

(이 기술은 x축 또는 y축인 회전의 축에 따른 단위벡터를 찾는데 유용하다. 추가적으로 2x2 행렬은 두 직교 단위 벡터로 부터 만들어질 수 있고 각 벡터는 직접 행에 넣을 수 있다. 하지만 이 제작 메소드는 2D 물리엔진에서 약간 굉장하고 이것은 여전히 어떻게 회전하고 행렬들이 일반적으로 어떻게 작동되는지 이해하는데 매우 유용하다.)

This constructor might look something like:



Since the most important operation of a rotation matrix is to perform rotations based off of an angle, it's important to be able to construct a matrix from an angle and multiply a vector by this matrix (to rotate the vector counter-clockwise by the angle the matrix was constructed with):

(회전 행렬의 매우 중요한 연산은 각도를 기반으로 회전을 하는 것이다. 이것은 각도와 이 행렬의 벡터를 곱하여 행렬을 만들 수 있게하는 중요한 것이다.(반시계방향의 회전을 위해서는 만들어진 행렬의 각도로 함께):)



For the sake of brevity I will not derive why the counter-clockwise rotation matrix is of the form:

(이 글의 간략화를 위해 나는 반시계방향의 회전 행렬의 형식을 유도하지 않을 것이다.)


However it is important to at the very least know that this is the form of the rotation matrix. For more information about rotation matrices please see the Wikipedia page.

(회전 행렬에 대해 더 알고 싶으면 사이트 들어가 보라는 내용)


 

It is important to understand the difference between model and world space. Model space is the coordinate system local to a physics shape. The origin is at the COM, and the orientation of the coordinate system is aligned with the axes of the shape itself.

In order to transform a shape into world space it must be rotated and translated. Rotation must occur first, as rotation is always performed about the origin. Since the object is in model space (origin at COM), rotation will rotate about the COM of the shape. Rotation would occur with a Mat22 matrix. In the sample code, orientation matrices are of the name u.

(이것은 모델과 월드 공간의 차이를 이해하는데 중요하다. 모델 공간은 물리 모형의 로컬 좌표 시스템이다. 원점은 질량의 중심이고 모형 자기자신의 축에 정렬된 좌표 시스템의 방향이다. 월드 공간으로 모형을 변형하기 위해서는 반드시 회전과 이동이 되어있어야한다. 회전은 반드시 먼저 나와야하고 회전은 항상 원점에서 수행된다. 물체는 월드 공간일때부터(원점은 질량 중심에) 회전은 모형의 질량 중심에서 회전한다. 회전은 2x2 행렬로 나타내라. 샘플 코드에서는 u의 이름을 가진 방향 행렬들이다.)


After rotation is performed, the object can then be translated to its position in the world by vector addition.

(회전이 수행된 이후에 그 물체는 벡터 덧셈으로 그것의 위치가 이동될 수 있다.


Once an object is in world space, it can then be translated to the model space of an entirely different object by using inverse transformations. Inverse rotation followed by inverse translation are used to do so. This is how much math is simplified during collision detection!

(일단 한 오브젝트가 월드 공간안에 있으면 이것은 역변환을 사용함으로써 완전히 다른 물체의 모델공간으로의 이동이 될 수 있다. 역회전도 역이동을 사용함으로써 따라온다. 이것은 충돌 검출동안 꽤 수학이 간소화되었다!)


Inverse transformation from world space to model space of the red polygon.
Inverse transformation (left to right) from world space to model space of the red polygon.(월드 공간에서 붉은 다각형의 모델 공간으로의 역 변환(왼쪽을 오른쪽으로))

 

As seen in the above image, if the inverse transformation of the red object is applied to both the red and blue polygons, then a collision detection test can be reduced to the form of an AABB vs OBB test, instead of computing complex math between two oriented shapes.

(위 이미지에서 본것처럼 만약 붉은 물체의 역 변환이 붉은 다각형과 파란 다각형 둘 다 적용된다면 충돌 검출 테스트는 두개의 방향성 모형의 복잡한 수학 계산 대신 AABB 대 OBB 테스트의 형식으로 줄어들 수 있다.)


In much of the sample source code, vertices are constantly transformed from model to world and back to model, for all sorts of reasons. You should have a clear understanding of what this means in order to comprehend the sample collision detection code.

(대부분의 샘플코드에서 정점들은 지속적으로 모델에서 월드로 반대로 모델 공간으로 변환된다.)




In this section, I'll present quick outlines of polygon and circle collisions. Please see the sample source code for more in-depth implementation details. (다각형과 원 충돌의 빠른 개요만 소개하고 자세한 것은 코드로 볼 것)


Lets start with the most complex collision detection routine in this entire article series. The idea of checking for collision between two polygons is best done (in my opinion) with the Separating Axis Theorem (SAT).

(이 글 시리즈의 가장 복잡한 충돌 검출 루틴을 시작할 것이다. 분리축 정리를 이용하여 두 다각형 사이의 충돌을 체크하는 아이디어는 최고로 잘되어 있다(내 의견))


However, instead of projecting each polygon's extents onto each other, there is a slightly newer and more efficient method, as outlined by Dirk Gregorius in his 2013 GDC Lecture (slides available here for free).

(하지만 각 다각형의 크기 서로 투영하는 것 대신 Dirk Gregorius에 의해 발표된 더 간단하고 효율적인 방법이 있다)


The first thing that must be learned is the concept of support points.

(먼저 점들을 지지점 컨셉을 먼저 배울 것이다.)

The support point of a polygon is the vertex that is the farthest along a given direction. If two vertices have equal distances along the given direction, either one is acceptable.

(다각형의 지지점은 주어진 방향에 따라 먼 정점이다. 만약 두 정점은 주어진 방향을 따라 동일한 거리일 경우 둘 중 하나가 허용된다.)

In order to compute a supporting point, the dot product must be used to find a signed distance along a given direction. Since this is very simple, I'll show a quick example within this article:

(지지점을 계산하기 위해서 내적은 반드시 주어진 방향에 따라 부호가 있는 거리를 찾는 데 사용되어야 한다. 이것때문에 매우 심플하고 나는 빠르게 예제를 보여주겠다.)



The dot product is used on each vertex. The dot product represents a signed distance in a given direction, so the vertex with the greatest projected distance would be the vertex to return. This operation is performed in model space of the given polygon within the sample engine.

(내적은 각 정점에 사용한다. 내적은 반드시 주어진 방향에 따라 부호가 있는 거리를 찾는 데 사용되어야 해야해서 최대 투영거리가 정점이 되어 돌아올 것이다. 이 연산은 샘플엔진에서 주어진 다각형의 모델 공간으로 수행된다.)

By using the concept of support points, a search for the axis of separation can be performed between two polygons (polygon A and polygon B). The idea of this search is to loop along all faces of polygon A and find the support point in the negative normal to that face.

(지지점들의 개념을 사용하여 분리축을 찾아 두 다각형(다각형 A와 다각형 B) 사이의 작업을 수행하는 것이다. 이 찾기 아이디어는 검색 아이디어 다각형 A의 모든 표면 따라 루프되고 표면에 음수인 노멀을 갖는 지지점 찾는다.)

SupportPoints

In the above image, two support points are shown: one on each object. The blue normal would correspond to the supporting point on the other polygon as the vertex farthest along in the opposite direction of the blue normal. Similarly, the red normal would be used to find the support point located at the end of the red arrow.

(위 이미지에서 각 물체당 하나씩해서 두개의 지지점들이 보인다. 파란색 노멀은 다른 다각형에서 파란 노멀의 반대방향으로 있는 가장 먼 정점의 지지점에 일치할 것이다. 비슷하게 빨간 노멀은 빨간 화살표의 끝에 위치한 지지점을 찾는데 이용한다.)


The distance from each supporting point to the current face would be the signed penetration. By storing the greatest distance a possible minimum axis of penetration can be recorded.

(각각의 지지점으로부터의 현재 면까지의 거리는 부호를 가진 관통이 된다. 저장을 위해 가장 거리가 작고 침투 가능한 최소 축이 기록 될 수 있다.)


Here is an example function from the sample source code that finds the possible axis of minimum penetration using the Getsurpport() function:

(샘플 소스코드의 작은 침투의 축을 찾는 Getsurpport()함수를 보여주겠다.)



Since this function returns the greatest penetration, if this penetration is positive that means the two shapes are not overlapping (negative penetration would signify no separating axis).

(이 함수가 최대 침투를 리턴하기 때문에 만약 침투가 양수이면 두 모형이 오버랩되지 않는(중복되지 않는) 것을 의미한다(음수의 침투는 분리축이 없는 것을 의미한다.)


This function will need to be called twice, flipping A and B objects each call.

(이 함수는 A와 B 물체를 뒤집는데 각각 호출 해 2번 호출될 필요가 있다.)

From here, the incident and reference face need to be identified, and the incident face needs to be clipped against the side planes of the reference face. This is a rather non-trivial operation, although Erin Catto (creator of Box2D, and all physics currently used by Blizzard) has created some great slides covering this topic in detail.

(여기에서 입사와 레퍼런스 표면은 식별될 필요가 있고 입사면은 레퍼런스 표면의 사이드 평면에 대한 자르기가 필요하다. 이것은 차라리 사소하지 않은 것이고 Erin Catto (Box2D의 창조자, 현재 블리자드에서 모든 물리를 사용한다.)가 이 주제에 대한 자세한 멋진 슬라이드를 만들었다)


This clipping will generate two potential contact points. All contact points behind the reference face can be considered contact points.

(이 클리핑은 두개의 잠재적인 접점들을 만든다. 레퍼런스 표면 뒤의 모든 접점들은 접점들로 고려할 수 있다.)

Beyond Erin Catto's slides, the sample engine also has the clipping routines implemented as an example.

( Erin Catto의 슬라이드를 넘어서 그 샘플 엔진은 또한 클리핑 루틴이 시행된다.)

The circle vs. polygon collision routine is quite a bit simpler than polygon vs. polygon collision detection. First, the closest face on the polygon to the center of the circle is computed in a similar way to using support points from the previous section: by looping over each face normal of the polygon and finding the distance from the circle's center to the face.

(그 원 vs 다각형 충돌 루틴은 다각형 vs 다각형 충돌 검출보다 꽤 심플하다. 먼저 다각형의 가까운 표면에서 원의 중심으로는 이전 섹션의 지지점을 사용하는 것 비슷한 방법으로 계산된다. 다각형의 각 표면 노멀과 원의 중심에서 표면까지의 거리를 찾는 것이 반복된다.)


If the center of the circle is behind this closest face, specific contact information can be generated and the routine can immediately end.

(이 가까운 면 뒤에 원의 중심이 있다면 특정 접촉 정보는 전환될 수 있고 루틴이 즉시 종료될 수 있다.)


After the closest face is identified, the test devolves into a line segment vs. circle test. A line segment has three interesting regions called Voronoi regions. Examine the following diagram:

(가까운 면이 식별된 뒤 선분 vs 원 테스트를 한다. 선분은 3개의 흥미로운 지역을 갖는데 이것을 보로노이 지역이라고 부른다. 이 다이어그램으로 예를 든다:)

Voronoi regions of a line segment.
Voronoi regions of a line segment.(선분의 보로노이 지역)

Intuitively, depending on where the center of the circle is located different contact information can be derived. Imagine the center of the circle is located on either vertex region. This means that the closest point to the circle's center will be an edge vertex, and the proper collision normal will be a vector from this vertex to the circle center.

(직관적으로 원의 중심의 위치에 따라 위치된 다른 접촉 정보가 파생될 수도 있다. 원의 중심 그림은 각각의 지역에 배치된다. 이것은 가까운 점에서 원의 중심는 끝 정점이 될 것이고 적절한 충돌 노멀은 정점으로부터 원의 중심까지의 벡터가 될 것이다.)


If the circle is within the face region then the closest point of the segment to the circle's center will be the circle's center project onto the segment. The collision normal will just be the face normal.

(만약 원이 표면 지역에 있으면 선분의 가까운 점에서 원의 중심까지는 원의 중심에서 선분방향으로의 투영이 될것이다. 충돌 노멀은 단지 표면 노멀이 될 것이다.)


To compute which Voronoi region the circle lies within, we use the dot product between a couple of vertices. The idea is to create an imaginary triangle and test to see whether the angle of the corner constructed with the segment's vertex is above or below 90 degrees. One triangle is created for each vertex of the line segment.

(어떤 보로노이 지역안의 원을 계산하기 위해 우리는 한쌍의 정점들의 내적을 사용한다. 이 아이디어는 상상의 삼각형을 만들고 코너의 각도 만들어진 선분의 정점 위로 또는 아래로 90도를 테스트한다???????????)

Projecting vector from edge vertex to circle center onto the edge.
Projecting vector from edge vertex to circle center onto the edge.(정점의 끝에서 원의 중심까지의 투영 벡터)

A value of above 90 degrees will mean an edge region has been identified. If neither triangle's edge vertex angles is above 90 degrees, then the circle's center needs to be projected onto the segment itself to generate manifold information. As seen in the image above, if the vector from the edge vertex to the circle center dotted with the edge vector itself is negative, then the Voronoi region the circle lies within is known.

(90도 이상의 값은 모서리 지역이 식별되었다는 것을 의미한다. 만약 삼각형의 모서리 정점 각도들이 90도 이상이 아니면 원의 중심에서 자기 자신이 매니폴드 정보로 전환하는 선분으로 투영할 필요가 있다. 위 이미지에서 보듯이 만약 정점의 끝부터 원의 중심까지의 벡터 /가장자리 벡터 점재하고있는 경우, 그 자체가 음수이면 보로노이 지역은 거짓 원을 알 것이다.???????????)


Luckily, the dot product can be used to compute a signed projection, and this sign will be negative if above 90 degrees and positive if below.

(운이 좋게도 내적을 부호를 가진 투영을 계산하는데 이용할 수 있고 이 부호는 만약 90도 이상이면 마이너스가 될 것이고 이하이면

플러스이다.)

It is that time again: we'll return to our impulse resolution code for a third and final time. By now, you should be fully comfortable writing their own resolution code that computes resolution impulses, along with friction impulses, and can also can performed linear projection to resolve leftover penetration.

(그 시간이 돌아왔다: 우리는 충돌 해결 코드를 세번째와 마지막에 되찾았다. 지금까지 마찰 충격에 따라 충돌을 해결하는 코드를 편하게 작성해야 하고 또한 남은 침투를 해결하기 위해 선형 투영을 수행할 수 있다.)


Rotational components need to be added to both the friction and penetration resolution. Some energy will be placed into angular velocity.

(회전 컴포넌트는 마찰과 침투 해결 모두 추가할 필요가 있다. 어떤 에너지는 각속도에 위치한다.)


Here is our impulse resolution as we left it from the previous article on friction:

(여기 우리가 이전 글인 마찰에서 가져온 충격 해결법이다.)


Equation 5

j%3D%5Cfrac%20%7B%20-(1%2Be)((%5Ccombi%20%5E%7B%20A%20%7D%7B%20V%20%7D-%5Ccombi%20%5E%7B%20B%20%7D%7B%20V%20%7D)*t)%20%7D%7B%20%5Cfrac%20%7B%201%20%7D%7B%20%5Ccombi%20%5E%7B%20A%20%7D%7B%20mass%20%7D%20%7D%2B%5Cfrac%20%7B%201%20%7D%7B%20%5Ccombi%20%5E%7B%20B%20%7D%7B%20mass%20%7D%20%7D%20%7D%20

If we throw in rotational components, the final equation looks like this:

(만약 우리가 회전 컴포넌트를 넣는다면 마지막에는 이렇게 나타난다.)


Equation 6

j%3D%5Cfrac%20%7B%20-(1%2Be)((%5Ccombi%20%5E%7B%20A%20%7D%7B%20V%20%7D-%5Ccombi%20%5E%7B%20B%20%7D%7B%20V%20%7D)*t)%20%7D%7B%20%5Cfrac%20%7B%201%20%7D%7B%20%5Ccombi%20%5E%7B%20A%20%7D%7B%20mass%20%7D%20%7D%2B%5Cfrac%20%7B%201%20%7D%7B%20%5Ccombi%20%5E%7B%20B%20%7D%7B%20mass%20%7D%20%7D%2B%5Cfrac%20%7B%20%5Ccombi%20%5E%7B%202%20%7D%7B%20(%5Ccombi%20%5E%7B%20A%20%7D%7B%20r%20%7D%5Ctimes%20t)%20%7D%20%7D%7B%20%5Ccombi%20%5E%7B%20A%20%7D%7B%20I%20%7D%20%7D%2B%5Cfrac%20%7B%20%5Ccombi%20%5E%7B%202%20%7D%7B%20(%5Ccombi%20%5E%7B%20B%20%7D%7B%20r%20%7D%5Ctimes%20t)%20%7D%20%7D%7B%20%5Ccombi%20%5E%7B%20B%20%7D%7B%20I%20%7D%20%7D%20%7D%20

In the above equation, r is again a "radius", as in a vector from the COM of an object to the point of contact. A more in-depth derivation of this equation can be found on Chris Hecker's site.

(위 식에서 r은 반지름이고 질량 중심으로 부터 접점으로의 벡터이다. 이 식에 대해 더 파헤치고 싶다면 크리스 헤커의 사이트에 가봐라.)

It is important to realize that the velocity of a given point on an object is:

(이것은 물체위의 주어지는 점의 속도를 깨닫는데 중요하다.)

Equation 7

%5Ccombi%20%5E%7B%20'%20%7D%7B%20V%20%7D%3DV%2Bw%5Ctimes%20r%20


The application of impulses changes slightly in order to account for the rotational terms:

(임펄스 적용이 회전 조건을 위해 변화됨)




This concludes the final article of this series. By now, quite a few topics have been covered, including impulse based resolution, manifold generation, friction, and orientation, all in two dimensions.

If you've made it this far, I must congratulate you! Physics engine programming for games is an extremely difficult area of study. I wish all readers luck, and again please feel free to comment or ask questions below.

(이런거 저런거 했고 축하한다고...)


-----------------------------------------

번역 끝~~~

근데 발번역이라 내가 쓴글도 내가 뭔소린지 못알아먹겠음 ㅋㅋㅋㅋ



(네이버 블로그 - 2016.02.20. 21:50)


,

최근 댓글

최근 트랙백

알림

이 블로그는 구글에서 제공한 크롬에 최적화 되어있고, 네이버에서 제공한 나눔글꼴이 적용되어 있습니다.

태그

카운터

Today :
Yesterday :
Total :