MCPcopy Create free account
hub / github.com/davisking/dlib / generate_circle

Function generate_circle

examples/linear_manifold_regularizer_ex.cpp:263–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261dlib::rand rnd;
262
263void generate_circle (
264 std::vector<sample_type>& samples,
265 double radius,
266 const long num
267)
268{
269 sample_type m(2,1);
270
271 for (long i = 0; i < num; ++i)
272 {
273 double sign = 1;
274 if (rnd.get_random_double() < 0.5)
275 sign = -1;
276 m(0) = 2*radius*rnd.get_random_double()-radius;
277 m(1) = sign*sqrt(radius*radius - m(0)*m(0));
278
279 samples.push_back(m);
280 }
281}
282
283// ----------------------------------------------------------------------------------------
284

Callers 2

do_the_testMethod · 0.85

Calls 3

get_random_doubleMethod · 0.80
sqrtFunction · 0.50
push_backMethod · 0.45

Tested by 2

do_the_testMethod · 0.68