Showing posts with label 수학. Show all posts
Showing posts with label 수학. Show all posts
2010/02/01
직선에서 점사이의 거리
두 점 P1(0, 2) 과 P2(8, 6) 을 지나는 직선에서 점 P(4, 8) 사이의 거리.
두 점을 지나는 직선의 방정식: y = 1/2x + 2, 1/2x -y + 2 = 0
직선과 두 점 사이의 거리: | 1/2 * 4 + -1 * 8 + 2 | / sqrt( 1/2 * 1/2 + -1 * -1 ) = 3.
Original Post : http://neodreamer-dev.tistory.com/367
2009/09/02
다각형의 면적과 무게 중심 구하기
업무 때문에 찾아 본 자료이다. 다각형의 면적과 무게 중심을 구하는 공식인데 생각보다는 심플 한데 이해가 쉽지는 않다. 공부를 해야겠지....

위와 같은 좌표 구성의 다각형이 있을때 면적과 무게 중심 값은 아래와 같다.



위 식을 이용하는 코드를 C++로 작성해 보았다.
출처 : Calculating the area and centroid of a polygon
참고 : Polygon Area -- from Wolfram MathWorld
Original Post : http://neodreamer-dev.tistory.com/317
위와 같은 좌표 구성의 다각형이 있을때 면적과 무게 중심 값은 아래와 같다.
위 식을 이용하는 코드를 C++로 작성해 보았다.
for (i = 0; i < points; i++)
{
j = (i + 1) % points;
pt1 = pPoly->GetPointAt(i);
pt2 = pPoly->GetPointAt(j);
x1 = pt1.x;
x2 = pt2.x;
y1 = pt1.y;
y2 = pt2.y;
area += x1 * y2;
area -= y1 * x2;
centerx += ((x1 + x2) * ((x1 * y2) - (x2 * y1)));
centery += ((y1 + y2) * ((x1 * y2) - (x2 * y1)));
}
area /= 2.0;
area = fabs(area);
centerx = centerx / (6.0 * area);
centery = centery / (6.0 * area);
출처 : Calculating the area and centroid of a polygon
참고 : Polygon Area -- from Wolfram MathWorld
Original Post : http://neodreamer-dev.tistory.com/317
Labels:
Area of Polygon
,
C++
,
Centroid of Polygon
,
polygon
,
TistoryOldPost
,
다각형의 면적
,
다각형의 무게중심
,
도형
,
면적공식
,
면적구하기
,
무게중심 공식
,
무게중심 구하기
,
수학
Subscribe to:
Posts
(
Atom
)