-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimFunction.cxx
56 lines (47 loc) · 947 Bytes
/
TimFunction.cxx
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
#include "TimFunction.hxx"
#include <cmath>
#define EPSILON 1.5
void EllipseFunction::ReadFromStream(fstream &InputStream)
{
InputStream>>x0;
InputStream>>y0;
InputStream>>A;
InputStream>>B;
InputStream>>Color;
}
EllipseFunction::EllipseFunction()
{
A = 150;
B = 200;
x0 = 0;
y0 = 0;
}
EllipseFunction::~EllipseFunction()
{
}
bool EllipseFunction::Function(float X, float Y)
{
float temp = pow(X - x0, 2) / (A * A) + pow(Y - y0, 2) / (B * B);
return temp <= 1;
}
void JorFunction::ReadFromStream(fstream &InputStream)
{
InputStream>>x0;
InputStream>>y0;
InputStream>>P;
}
JorFunction::JorFunction()
{
x0 = -50;
y0 = -50;
P = 1;
}
JorFunction::~JorFunction()
{
}
bool JorFunction::Function(float X, float Y)
{
return fabsf(sqrtf(2*P*(X-x0))-Y+y0) < EPSILON || fabsf(-sqrtf(2*P*(X-x0))-Y+y0) < EPSILON ||
fabsf(pow(Y - y0, 2) * 0.5 / P + x0 - X) < EPSILON;
//return fabsf(pow(Y - y0, 2) - 2 * P * (X - x0)) < P;
}