-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtracer.cc
99 lines (62 loc) · 1.17 KB
/
tracer.cc
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
#include "tracer.h"
extern void prn(Vector);
void OptBench::make_outgoing()
{
Vnode *anode;
Ray temp;
anode=head;
anode->set_incoming(incoming);
anode->make_outgoing();
while(anode!=tail){
temp=anode->get_outgoing();
anode=anode->next;
anode->set_incoming(temp);
anode->make_outgoing();
if(!(inside=anode->is_inside())) return;
}
outgoing=anode->get_outgoing();
}
double OptBench::efficiency(Ray in)
{
Vnode *node;
double eff=1.;
double t;
incoming=in;
make_outgoing();
node=head;
while(node!=tail){
eff *= (node->efficiency());
node=node->next;
}
t = tail->efficiency();
eff*=t;
return(eff);
}
void List::add_node(Vnode *anode,int order)
{
int i;
Vnode *temp;
temp=head;
if(head==NULL)
{
head=anode;
tail=head;
head->next=tail;
return;
}
if(order==LAST)
{
tail->next=anode;
anode->next=tail->next;
tail=anode;
return;
}
for(i=1;i<order&&temp!=tail;i++) temp=temp->next;
temp->next=anode;
anode->next=temp->next;
if(temp==tail) tail=anode;
}
void mem_error(char *s)
{
cout<<"can't allocate memory for:"<<s<<endl;
}