Panda3D
arcEmitter.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file arcEmitter.cxx
10  * @author charles
11  * @date 2000-06-22
12  */
13 
14 #include "arcEmitter.h"
15 
16 /**
17  * constructor
18  */
21  RingEmitter(), _start_theta(0.0f), _end_theta(MathNumbers::pi_f)
22 {
23 }
24 
25 /**
26  * copy constructor
27  */
29 ArcEmitter(const ArcEmitter &copy) :
30  RingEmitter(copy) {
31  _start_theta = copy._start_theta;
32  _end_theta = copy._end_theta;
33 }
34 
35 /**
36  * destructor
37  */
40 }
41 
42 /**
43  * copier
44  */
47  return new ArcEmitter(*this);
48 }
49 
50 /**
51  * Generates a location for a new particle
52  */
53 void ArcEmitter::
54 assign_initial_position(LPoint3& pos) {
55  PN_stdfloat theta;
56  if ( _start_theta < _end_theta ) {
57  theta = LERP(NORMALIZED_RAND(), _start_theta, _end_theta);
58  } else {
59  theta = LERP(NORMALIZED_RAND(), _start_theta, _end_theta + 2.0f * MathNumbers::pi_f);
60  }
61 
62  theta += (MathNumbers::pi_f / 2.0);
63  this->_cos_theta = cosf(theta);
64  this->_sin_theta = sinf(theta);
65 
66  PN_stdfloat new_radius_spread = SPREAD(_radius_spread);
67  PN_stdfloat new_x = _cos_theta * (_radius + new_radius_spread);
68  PN_stdfloat new_y = _sin_theta * (_radius + new_radius_spread);
69 
70  pos.set(new_x, new_y, 0.0f);
71 }
72 
73 /**
74  * Write a starc representation of this instance to <out>.
75  */
76 void ArcEmitter::
77 output(std::ostream &out) const {
78  #ifndef NDEBUG //[
79  out<<"ArcEmitter";
80  #endif //] NDEBUG
81 }
82 
83 /**
84  * Write a starc representation of this instance to <out>.
85  */
86 void ArcEmitter::
87 write(std::ostream &out, int indent) const {
88  #ifndef NDEBUG //[
89  out.width(indent); out<<""; out<<"ArcEmitter:\n";
90  out.width(indent+2); out<<""; out<<"_start_angle "<<rad_2_deg(_start_theta)<<"\n";
91  out.width(indent+2); out<<""; out<<"_end_angle "<<rad_2_deg(_end_theta)<<"\n";
92  RingEmitter::write(out, indent+2);
93  #endif //] NDEBUG
94 }
Describes a planar ring region in which particles are generated.
Definition: arcEmitter.h:22
ArcEmitter()
constructor
Definition: arcEmitter.cxx:20
virtual BaseParticleEmitter * make_copy()
copier
Definition: arcEmitter.cxx:46
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
Describes a planar ring region in which particles are generated.
Definition: ringEmitter.h:22
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition: indent.cxx:20
virtual void output(std::ostream &out) const
Write a starc representation of this instance to <out>.
Definition: arcEmitter.cxx:77
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual ~ArcEmitter()
destructor
Definition: arcEmitter.cxx:39
virtual void write(std::ostream &out, int indent=0) const
Write a starc representation of this instance to <out>.
Definition: arcEmitter.cxx:87