Esempio n. 1
0
void move(struct mat * ro, struct mat * RO_r, struct mat * RO_n, struct mat * r,
          struct mat * u, struct mat * n)
{
    double a = MGET(r, 2, 0);
    double dx = MGET(u, 0, 0) + MGET(n, 0, 0);
    double da = MGET(u, 1, 0) + MGET(n, 1, 0);

    double ao = a + da;

    //printf("ao = %f\n", ao);
    if (ao > M_PI)
    {
        ao = ao - 2.0 * M_PI;
    }
    if (ao < -M_PI)
    {
        ao = ao + 2.0 * M_PI;
    }

    struct mat * dp = mat(2, 1);

    MSET(dp, 0, 0, dx);
    //MSET(dp, 1, 0, da);

    struct mat * to = mat(2, 1);
    struct mat * TO_r = mat(2, 3);
    struct mat * TO_dt = mat(2, 2);

    from_frame(to, TO_r, TO_dt, r, dp);

    float AO_a = 1;
    float AO_da = 1;

    copy_into(RO_r, TO_r, 0, 0);
    MSET(RO_r, 2, 0, 0);
    MSET(RO_r, 2, 1, 0);
    MSET(RO_r, 2, 2, AO_a);

    copy_into(RO_n, TO_dt, 0, 0);
    MSET(RO_n, 0, 1, 0);
    MSET(RO_n, 1, 1, 0);
    MSET(RO_n, 2, 1, AO_da);

    //print_mat(to);
    //printf("%f\n", ao);

    copy_into(ro, to, 0, 0);
    MSET(ro, 2, 0, ao);

    free(to);
    free(TO_r);
    free(TO_dt);
    free(dp);
}
Esempio n. 2
0
bool RakeResults<SampleSeq>::copy_to_user()
{
  typename SampleSeq::PrivateMemberAccess received_data_p(received_data_);

  if (do_sort_) {
    size_t len = std::min(static_cast<size_t>(sorted_.size()),
                          static_cast<size_t>(max_samples_));
    received_data_p.internal_set_length(static_cast<CORBA::ULong>(len));
    info_seq_.length(static_cast<CORBA::ULong>(len));
    return copy_into(sorted_.begin(), sorted_.end(), received_data_p);

  } else {
    size_t len = unsorted_.size(); //can't be larger than max_samples_
    received_data_p.internal_set_length(static_cast<CORBA::ULong>(len));
    info_seq_.length(static_cast<CORBA::ULong>(len));
    return copy_into(unsorted_.begin(), unsorted_.end(), received_data_p);
  }
}
Esempio n. 3
0
bool
TextureAtlas::insert(TexturePatch::ConstPtr texture_patch, float vmin, float vmax) {
    assert(bin != NULL);
    assert(validity_mask != NULL);

    int const width = texture_patch->get_width() + 2 * padding;
    int const height = texture_patch->get_height() + 2 * padding;
    Rect<int> rect(0, 0, width, height);
    if (!bin->insert(&rect)) return false;

    /* Update texture atlas and its validity mask. */
    mve::ByteImage::Ptr patch_image = mve::image::float_to_byte_image(
        texture_patch->get_image(), vmin, vmax);
    mve::image::gamma_correct(patch_image, 1.0f / 2.2f);

    copy_into(patch_image, rect.min_x, rect.min_y, image, padding);
    mve::ByteImage::ConstPtr patch_validity_mask = texture_patch->get_validity_mask();
    copy_into(patch_validity_mask, rect.min_x, rect.min_y, validity_mask, padding);

    TexturePatch::Faces const & patch_faces = texture_patch->get_faces();
    TexturePatch::Texcoords const & patch_texcoords = texture_patch->get_texcoords();

    /* Calculate the offset of the texture patches' relative texture coordinates */
    math::Vec2f offset = math::Vec2f(rect.min_x + padding, rect.min_y + padding);

    faces.insert(faces.end(), patch_faces.begin(), patch_faces.end());

    /* Calculate the final textcoords of the faces. */
    for (std::size_t i = 0; i < patch_faces.size(); ++i) {
        for (int j = 0; j < 3; ++j) {
            math::Vec2f rel_texcoord(patch_texcoords[i * 3 + j]);
            math::Vec2f texcoord = rel_texcoord + offset;

            texcoord[0] = texcoord[0] / (this->size - 1);
            texcoord[1] = texcoord[1] / (this->size - 1);
            texcoords.push_back(texcoord);
        }
    }
    return true;
}
Esempio n. 4
0
bool append_func(php::Func* dst, const php::Func& src) {
  if (src.numIters || src.locals.size()) return false;
  if (src.exnNodes.size() && dst->exnNodes.size()) return false;

  bool ok = false;
  for (auto& b : dst->blocks) {
    if (b->hhbcs.back().op != Op::RetC) continue;
    auto const blk = b.mutate();
    blk->hhbcs.back() = bc::PopC {};
    blk->fallthrough = dst->blocks.size();
    ok = true;
  }
  if (!ok) return false;
  copy_into(dst, src);
  return true;
}
Esempio n. 5
0
File: bot.c Progetto: ct187/irc-bot
static struct irc_message *recv_msg()
{
	char buf[IRC_BUF_LENGTH];
	char *prefix = NULL, *command = NULL, *params = NULL, *tok;
	struct irc_message *irc_msg;
	int i, bo = 0;

	do
	{
		if (*recv_buf_pos == '\0' && fill_recv_buf())
			return NULL;

		i = copy_into(recv_buf_pos, buf + bo, IRC_BUF_LENGTH - bo);
		if (i == -1) {
			log_err("Message received that exceeds IRC message "
					"length [%d].", IRC_BUF_LENGTH);
			return NULL;

		}
		recv_buf_pos += i;
		bo += i;
	} while (buf[bo] != '\n');

	recv_buf_pos++;
	buf[bo+1] = '\0';

	tok = strtok(buf, " ");
	if (tok[0] != ':') {
		command = tok;
	} else {
		prefix = tok;
		command = strtok(NULL, " ");
	}

	if ((tok = strtok(NULL, "\r\n")) != NULL) {
		params = tok;
	}

	irc_msg = create_message(prefix, command, params);
	debug("%%Received message--\n"
	      "%%prefix:  \"%s\"\n"
	      "%%command: \"%s\"\n"
	      "%%params:  \"%s\"",
	      irc_msg->prefix, irc_msg->command, irc_msg->params);

	return irc_msg;
}
Esempio n. 6
0
php::FuncBase::FuncBase(const FuncBase& other) {
  copy_into(this, other);

  assertx(!other.nativeInfo);
}