ジオメトリのいくつかのコードを計算します...


具体的な役割には注釈がある
 
?
View Code C
 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// darkscope.cpp : Defines the entry point for the console application.
//
 
// darkscope.cpp : Defines the entry point for the console application.
//
 
#include "stdafx.h"
#include 
#include 
#include 
#include 
const double eps=1e-8;
const double pi=3.1415926535897;
using namespace std;
struct point                    // 
{
	double x,y;
	point()
	{}
	point(double xx,double yy)
	{
		x=xx;y=yy;
	}
};
struct vect                    //  
{
	double x,y;
	vect()
	{}
	vect(double xx,double yy)
	{
		x=xx;
		y=yy;
	}
	vect(point a,point b)
	{
		x=b.x-a.x;
		y=b.y-a.y;
	}
};
double dot_product(vect a,vect b)			//  
{
	return a.x*b.x+a.y*b.y;
}
double cha_product(vect a,vect b)				//  
{
	return a.x*b.y-b.x*a.y;
}
bool cross(point a,point b,point c,point d)			//  ab,cd    ,    
{
	return cha_product(vect(a,c),vect(a,d))*cha_product(vect(b,c),vect(b,d))0?1:-1;
}
double square_of_polygan(vector
 a)  //       ,a            
{
	a.push_back(a[0]);
	double ans=0;
	for (int i=1;i k;
	k.push_back(a);k.push_back(c);k.push_back(d);
	double sacd=square_of_polygan(k);
	k.clear();k.push_back(b);k.push_back(c);k.push_back(d);
	double sbcd=square_of_polygan(k);
	point ans=point(a.x*sbcd/(sacd+sbcd)+b.x*sacd/(sacd+sbcd),a.y*sbcd/(sacd+sbcd)+b.y*sacd/(sacd+sbcd));
	return ans;
}
double angle_of_vector(vect a,vect b)                 //        ,       ,       ans*180/pi
{
	return acos((a.x*b.x+a.y*b.y)/(sqrt(a.x*a.x+a.y*a.y)*sqrt(b.x*b.x+b.y*b.y)));
}