当前位置: 首页>>代码示例>>C++>>正文


C++ B0函数代码示例

本文整理汇总了C++中B0函数的典型用法代码示例。如果您正苦于以下问题:C++ B0函数的具体用法?C++ B0怎么用?C++ B0使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了B0函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: B0

void Bezier::recalc(QPointF p)
{
	// http://www.flong.com/texts/code/shapers_bez/
	// http://www.lemoda.net/maths/bezier-length/index.html,

	// arbitrary but reasonable t-values for interior control points
	double t0 = 0.3;
	double t1 = 0.7;

	if (m_drag_cp0) {
		double x = (p.x() - m_endpoint0.x() * B0(t0) - m_cp1.x() * B2(t0) - m_endpoint1.x() * B3(t0)) / B1(t0);
		double y = (p.y() - m_endpoint0.y() * B0(t0) - m_cp1.y() * B2(t0) - m_endpoint1.y() * B3(t0)) / B1(t0);
		m_cp0 = QPointF(x, y);
	}
	else {
		double x = (p.x() - m_endpoint0.x() * B0(t1) - m_cp0.x() * B1(t1) - m_endpoint1.x() * B3(t1)) /  B2(t1);
		double y = (p.y() - m_endpoint0.y() * B0(t1) - m_cp0.y() * B1(t1) - m_endpoint1.y() * B3(t1)) /  B2(t1);
		m_cp1 = QPointF(x, y);
	}
	
	/*
	DebugDialog::debug(QString("ix:%1 p0x:%2,p0y:%3 p1x:%4,p1y:%5 px:%6,py:%7")
							.arg(m_drag_cp0)
							.arg(m_endpoint0.x())
							.arg(m_endpoint0.y())
							.arg(m_endpoint1.x())
							.arg(m_endpoint1.y())
							.arg(p.x())
							.arg(p.y())
							);
	*/

	m_isEmpty = false;
}
开发者ID:honsey,项目名称:fztaxedit,代码行数:34,代码来源:bezier.cpp

示例2: reallyroutespline

static int reallyroutespline (Pedge_t *edges, int edgen,
        Ppoint_t *inps, int inpn, Ppoint_t ev0, Ppoint_t ev1) {
    Ppoint_t p1, p2, cp1, cp2, p;
    Pvector_t v1, v2, splitv, splitv1, splitv2;
    double maxd, d, t;
    int maxi, i, spliti;

    static tna_t *tnas;
    static int tnan;

    if (tnan < inpn) {
        if (!tnas) {
            if (!(tnas = (tna_t *)malloc (sizeof (tna_t) * inpn)))
                return -1;
        } else {
            if (!(tnas = (tna_t *)realloc (tnas, sizeof (tna_t) * inpn)))
                return -1;
        }
        tnan = inpn;
    }
    tnas[0].t = 0;
    for (i = 1; i < inpn; i++)
        tnas[i].t = tnas[i - 1].t + dist (inps[i], inps[i - 1]);
    for (i = 1; i < inpn; i++)
        tnas[i].t /= tnas[inpn - 1].t;
    for (i = 0; i < inpn; i++) {
        tnas[i].a[0] = scale (ev0, B1 (tnas[i].t));
        tnas[i].a[1] = scale (ev1, B2 (tnas[i].t));
    }
    if (mkspline (inps, inpn, tnas, ev0, ev1, &p1, &v1, &p2, &v2) == -1)
        return -1;
    if (splinefits (edges, edgen, p1, v1, p2, v2, (inpn == 2 ? 1 : 0)))
        return 0;
    cp1 = add (p1, scale (v1, 1 / 3.0));
    cp2 = sub (p2, scale (v2, 1 / 3.0));
    for (maxd = -1, maxi = -1, i = 1; i < inpn - 1; i++) {
        t = tnas[i].t;
        p.x = B0 (t) * p1.x + B1 (t) * cp1.x +
                B2 (t) * cp2.x + B3 (t) * p2.x;
        p.y = B0 (t) * p1.y + B1 (t) * cp1.y +
                B2 (t) * cp2.y + B3 (t) * p2.y;
        if ((d = dist (p, inps[i])) > maxd)
            maxd = d, maxi = i;
    }
    spliti = maxi;
    splitv1 = normv (sub (inps[spliti], inps[spliti - 1]));
    splitv2 = normv (sub (inps[spliti + 1], inps[spliti]));
    splitv = normv (add (splitv1, splitv2));
    reallyroutespline (edges, edgen, inps, spliti + 1, ev0, splitv);
    reallyroutespline (edges, edgen, &inps[spliti], inpn - spliti, splitv, ev1);
    return 0;
}
开发者ID:crioux,项目名称:SpeedDemon-Profiler,代码行数:52,代码来源:route.cpp

示例3: B1

// Shortest cubic spline through 4 on-curve points(chord approximation)
void Bezier::FitSpline(Vec3 p[])
{
	// use chord length for shortest(best) cubic spline approximation
	float c3 = (p[1] - p[0]).Magnitude();
	float c2 = (p[2] - p[1]).Magnitude();
	float c1 = (p[3] - p[2]).Magnitude();

	// cases where p[1] is close to p[2] might lead to instabilities(need some heuristic)
	if (50 * c2 < c1 + c3)
	{
		p[1] = p[0] + (p[1] - p[0]) * 0.98;
		p[2] = p[3] + (p[2] - p[3]) * 0.98;
		c3 = c3 * 0.98;
		c2 = (p[2] - p[1]).Magnitude();
		c1 = c1 * 0.98;
	}

	float t1 = c1 / (c1 + c2 + c3);
	float t2 = (c1 + c2) / (c1 + c2 + c3);

	// Solve M * x = y
	float m00 = B1(t1);
	float m01 = B2(t1);
	float m10 = B1(t2);
	float m11 = B2(t2);

	float detM = m00 * m11 - m01 * m10;
	if (fabs(detM) > 1E-3)
	{
		// y = p - p0 * B0(t) - p3 * B3(t)
		Vec3 y1 = p[1] - p[0] * B0(t1) - p[3] * B3(t1);
		Vec3 y2 = p[2] - p[0] * B0(t2) - p[3] * B3(t2);

		// Minv
		float s = 1 / detM;
		float n00 = s * m11;
		float n01 = -s * m01;
		float n10 = -s * m10;
		float n11 = s * m00;

		// x = Minv * y
		Vec3 x1 = y1 * n00 + y2 * n01;
		Vec3 x2 = y1 * n10 + y2 * n11;

		p[1] = x1;
		p[2] = x2;
	}
}
开发者ID:Alexander-Eck,项目名称:vdrift,代码行数:49,代码来源:bezier.cpp

示例4: setmudim

complex LoopToolsWrapper::PV_B0(const double mu2, const double p2,
                                const double m02, const double m12) const
{
    setmudim(mu2);
    std::complex<double> B0val = B0(p2, m02, m12);
    return complex( B0val.real(), B0val.imag(), false );
}
开发者ID:shehu0,项目名称:HEPfit,代码行数:7,代码来源:LoopToolsWrapper.cpp

示例5: huddraw_help

int huddraw_help() {
    fg_color = B0(COLOR_BLACK);
    bg_color = B3(COLOR_WHITE);

    int i,l;

    for(i=0; HUD_HELP[i].title; i++) {
        if (!strcmp(hud_help_page, HUD_HELP[i].title)) {
            huddraw_help_text(HUD_HELP[i].text);
            return 1;
        }
    }

    char text[4096];
    sprintf(text,   "No help available for topic     \n"
                    "%s\n"
                    "\n"
                    "Use #hud help to see the list of\n"
                    "available commands and topics   \n"
                    "\n"
                    "Use #hud help <topic> for help  \n"
                    "on specific topic               \n",
                    hud_help_page);
    huddraw_help_text(text);

    return 1;
}
开发者ID:broese,项目名称:mcbuild,代码行数:27,代码来源:hud.c

示例6: huddraw_info_nav

void huddraw_info_nav(int r) {
    char text[256];

    fg_color = B0(COLOR_BLACK);
    bg_color = B3(COLOR_SAND_YELLOW);
    draw_rect(0,r,128,35,1);

    fg_color = B2(COLOR_SAND_YELLOW);
    draw_rect(35,r+2,12,14,0);
    draw_rect(76,r+2,12,14,0);

    // coordinates
    fg_color = B3(COLOR_REDSTONE_RED);
    bg_color = COLOR_TRANSPARENT;

    int32_t x = (int32_t)floor(gs.own.x);
    int32_t z = (int32_t)floor(gs.own.z);
    int32_t x_= (gs.world==&gs.nether) ? x*8 : x/8;
    int32_t z_= (gs.world==&gs.nether) ? z*8 : z/8;
    char *  n_= (gs.world==&gs.nether) ? "Overworld" : "Nether";

    draw_text(3, r+ 3, "X");
    draw_text(3, r+10, "Z");
    draw_text(3, r+19, "Y");
    draw_text(3, r+26, "DIR");

    sprintf(text, "%9d", x);  draw_text(11,r+3,text);
    sprintf(text, "%9d", x_); draw_text(53,r+3,text);
    sprintf(text, "%9d", z);  draw_text(11,r+10,text);
    sprintf(text, "%9d", z_); draw_text(53,r+10,text);
    sprintf(text, "%9d", (int32_t)floor(gs.own.y)); draw_text(11,r+19,text);

    char * dir = "UNKNOWN";
    switch(player_direction()) {
        case DIR_NORTH : dir = "NORTH"; break;
        case DIR_SOUTH : dir = "SOUTH"; break;
        case DIR_EAST  : dir = "EAST"; break;
        case DIR_WEST  : dir = "WEST"; break;
    }
    sprintf(text, "%9s", dir); draw_text(11,r+26,text);

    int pos = (42-(strlen(n_)*4-1))/2+49;
    draw_text(pos, r+26, n_);

    // compass
    huddraw_compass(108,r+17,B0(COLOR_BLACK), B3(COLOR_REDSTONE_RED));
}
开发者ID:broese,项目名称:mcbuild,代码行数:47,代码来源:hud.c

示例7: copy_from_flash

void copy_from_flash(unsigned long from, void *to,ssize_t len)
{   
        int i;  
        u8 *dest = (u8*)to;
        u16 data;
        unsigned long remap = (unsigned long)ioremap(FLASH_BASE_ADDR,FLASH_SIZE);
        u16 *src = (u16 *)(remap + from);

        for(i = 0; i < (len / 2);i++){
                data = src[i];
                dest[i * 2] = B0(data);
                dest[i * 2 + 1] = B1(data);

        }
        if(len & 1)
                dest[len - 1] = B0(src[i]);
	iounmap(remap);
}
开发者ID:mmk622,项目名称:ts_7500_kernel,代码行数:18,代码来源:str9100_tool.c

示例8: huddraw_info_health

void huddraw_info_health(int r) {
    char text[256];

    fg_color = B0(COLOR_BLACK);
    bg_color = B3(COLOR_GRASS_GREEN);
    draw_rect(0,r,128,12,1);

    bg_color = COLOR_TRANSPARENT;
    fg_color = B3(COLOR_REDSTONE_RED);
    draw_blit(fonts, FONTS_ICON_HEART, 8, 8, 2, r+2);
    fg_color = B0(COLOR_BLACK);
    sprintf(text, "%.1f", gs.own.health);
    draw_text(12, r+3, text);

    fg_color = B2(COLOR_ORANGE);
    draw_blit(fonts, FONTS_ICON_FOOD, 8, 8, 33, r+2);
    fg_color = B0(COLOR_BLACK);
    sprintf(text, "%d (%.1f)", gs.own.food, gs.own.saturation);
    draw_text(43, r+3, text);
}
开发者ID:broese,项目名称:mcbuild,代码行数:20,代码来源:hud.c

示例9: B0

secure_vector<byte> CCM_Mode::format_b0(size_t sz)
   {
   secure_vector<byte> B0(BS);

   const byte b_flags = (m_ad_buf.size() ? 64 : 0) + (((tag_size()/2)-1) << 3) + (L()-1);

   B0[0] = b_flags;
   copy_mem(&B0[1], m_nonce.data(), m_nonce.size());
   encode_length(sz, &B0[m_nonce.size()+1]);

   return B0;
   }
开发者ID:Andrew-He,项目名称:botan,代码行数:12,代码来源:ccm.cpp

示例10: B0

secure_vector<uint8_t> CCM_Mode::format_b0(size_t sz)
   {
   secure_vector<uint8_t> B0(CCM_BS);

   const uint8_t b_flags =
      static_cast<uint8_t>((m_ad_buf.size() ? 64 : 0) + (((tag_size()/2)-1) << 3) + (L()-1));

   B0[0] = b_flags;
   copy_mem(&B0[1], m_nonce.data(), m_nonce.size());
   encode_length(sz, &B0[m_nonce.size()+1]);

   return B0;
   }
开发者ID:Hackmanit,项目名称:botan,代码行数:13,代码来源:ccm.cpp

示例11: CAST5decrypt

void 
CAST5decrypt(const PGPUInt8 *in, PGPUInt8 *out, const PGPUInt32 *xkey)
{
	PGPUInt32 l, r, t;

	r = (PGPUInt32) in[0]<<24 | (PGPUInt32) in[1]<<16 | 
		(PGPUInt32) in[2]<<8 | in[3];

	l = (PGPUInt32) in[4]<<24 | (PGPUInt32) in[5]<<16 | 
		(PGPUInt32) in[6]<<8 | in[7];

	t = F1(l, xkey, 15); r ^= G1(t);
	t = F3(r, xkey, 14); l ^= G3(t);
	t = F2(l, xkey, 13); r ^= G2(t);
	t = F1(r, xkey, 12); l ^= G1(t);
	// Start here if only doing 12 rounds
	t = F3(l, xkey, 11); r ^= G3(t);
	t = F2(r, xkey, 10); l ^= G2(t);
	t = F1(l, xkey,  9); r ^= G1(t);
	t = F3(r, xkey,  8); l ^= G3(t);
	t = F2(l, xkey,  7); r ^= G2(t);
	t = F1(r, xkey,  6); l ^= G1(t);
	t = F3(l, xkey,  5); r ^= G3(t);
	t = F2(r, xkey,  4); l ^= G2(t);
	t = F1(l, xkey,  3); r ^= G1(t);
	t = F3(r, xkey,  2); l ^= G3(t);
	t = F2(l, xkey,  1); r ^= G2(t);
	t = F1(r, xkey,  0); l ^= G1(t);

	out[0]	= (PGPUInt8) B0(l);
	out[1]	= (PGPUInt8) B1(l);
	out[2]	= (PGPUInt8) B2(l);
	out[3]	= (PGPUInt8) B3(l);
	out[4]	= (PGPUInt8) B0(r);
	out[5]	= (PGPUInt8) B1(r);
	out[6]	= (PGPUInt8) B2(r);
	out[7]	= (PGPUInt8) B3(r);
}
开发者ID:ysangkok,项目名称:pgp-win32-6.5.8,代码行数:38,代码来源:Cast5.cpp

示例12: CAST5encrypt

/*
 * Encrypt the 8 bytes at *in into the 8 bytes at *out using the expanded
 * key schedule from *xkey.
 */
static void
CAST5encrypt(PGPByte const *in, PGPByte *out, PGPUInt32 const *xkey)
{
	PGPUInt32 l, r, t;

	l = (PGPUInt32)
		in[0]<<24 | (PGPUInt32)in[1]<<16 | (PGPUInt32)in[2]<<8 | in[3];
	r = (PGPUInt32)
		in[4]<<24 | (PGPUInt32)in[5]<<16 | (PGPUInt32)in[6]<<8 | in[7];

	t = F1(r, xkey,  0); l ^= G1(t);
	t = F2(l, xkey,  1); r ^= G2(t);
	t = F3(r, xkey,  2); l ^= G3(t);
	t = F1(l, xkey,  3); r ^= G1(t);
	t = F2(r, xkey,  4); l ^= G2(t);
	t = F3(l, xkey,  5); r ^= G3(t);
	t = F1(r, xkey,  6); l ^= G1(t);
	t = F2(l, xkey,  7); r ^= G2(t);
	t = F3(r, xkey,  8); l ^= G3(t);
	t = F1(l, xkey,  9); r ^= G1(t);
	t = F2(r, xkey, 10); l ^= G2(t);
	t = F3(l, xkey, 11); r ^= G3(t);
	/* Stop here if only doing 12 rounds */
	t = F1(r, xkey, 12); l ^= G1(t);
	t = F2(l, xkey, 13); r ^= G2(t);
	t = F3(r, xkey, 14); l ^= G3(t);
	t = F1(l, xkey, 15); r ^= G1(t);

	out[0] = B0(r);
	out[1] = B1(r);
	out[2] = B2(r);
	out[3] = B3(r);
	out[4] = B0(l);
	out[5] = B1(l);
	out[6] = B2(l);
	out[7] = B3(l);
}
开发者ID:ysangkok,项目名称:pgp-win32-6.5.8,代码行数:41,代码来源:pgpCAST5.c

示例13: huddraw_map

int huddraw_map() {
    int shading[16] = { 3, 3, 3, 3, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2 };

    if (!(hud_inv & HUDINVMASK_TUNNEL)) return 0;

    bg_color = B0(COLOR_BLACK);
    draw_clear();

    int32_t x = (int32_t)floor(gs.own.x);
    int32_t y = (int32_t)floor(gs.own.y);
    int32_t z = (int32_t)floor(gs.own.z);
    extent_t ex = { { x-80, y-12, z-80 }, { x+80, y+3, z+80 } };
    cuboid_t cb = export_cuboid_extent(ex);

    int r,c,i,j;
    int32_t off = cb.boff + 16*cb.sa.x + 16;
    for(r=0; r<128; r++) {
        for(c=0; c<128; c++) {
            int poff = off+r*cb.sa.x+c;
            for(j=0; j<16; j++) {
                if ( cb.data[j][poff].bid ) {
                    int8_t color = BLOCK_COLORMAP[cb.data[j][poff].bid][cb.data[j][poff].meta];
                    hud_image[r*128+c] = color*4 + shading[j];
                }
            }
        }
    }

    for(i=0; i<256; i++) lh_free(cb.data[i]);

    hud_image[64*128+64] = 126;

    char text[256];
    bg_color = B3(COLOR_WHITE);
    fg_color = B3(COLOR_REDSTONE_RED);
    sprintf(text, "%d,%d", x, z);
    draw_text(2, 2, text);
    sprintf(text, "Y:%d", y);
    draw_text(2, 9, text);

    bg_color = COLOR_TRANSPARENT;
    huddraw_compass(111, 16, B3(COLOR_GOLD_YELLOW), B3(COLOR_WHITE));

    return 1;
}
开发者ID:broese,项目名称:mcbuild,代码行数:45,代码来源:hud.c

示例14: huddraw_info_inv_item

void huddraw_info_inv_item(int id, float damage, int r) {
    int col = 4+31*(id%4);
    int row = r+2+10*(id/4);

    int fcol = FONTS_ICON_EQ_C+8*(id%4);
    int frow = FONTS_ICON_EQ_R+8*(id/4);

    bg_color = COLOR_TRANSPARENT;
    fg_color = (damage<0) ? B0(COLOR_CLAY_GRAY) : B3(COLOR_DIAMOND_BLUE);
    draw_blit(fonts, fcol, frow, 8, 8, col, row);

    fg_color = B2(COLOR_CLAY_GRAY);
    draw_rect(col+10, row+1, 16, 6, 1);

    if (damage >= 0) {
        fg_color = B3(COLOR_LAPIS_BLUE);
        if (damage < 1.0)  fg_color = B3(COLOR_EMERALD_GREEN);
        if (damage < 0.5)  fg_color = B3(COLOR_GOLD_YELLOW);
        if (damage < 0.25) fg_color = B3(COLOR_ORANGE);
        if (damage < 0.1)  fg_color = B3(COLOR_REDSTONE_RED);

        draw_rect(col+10, row+1, 16*damage, 6, 0);
    }
}
开发者ID:broese,项目名称:mcbuild,代码行数:24,代码来源:hud.c

示例15: test

	int test()
	{
		int Error = 0;

		int A0 = static_cast<int>(glm::log2(16.f));
		glm::ivec1 B0(glm::log2(glm::vec1(16.f)));
		glm::ivec2 C0(glm::log2(glm::vec2(16.f)));
		glm::ivec3 D0(glm::log2(glm::vec3(16.f)));
		glm::ivec4 E0(glm::log2(glm::vec4(16.f)));

		int A1 = glm::log2(int(16));
		glm::ivec1 B1 = glm::log2(glm::ivec1(16));
		glm::ivec2 C1 = glm::log2(glm::ivec2(16));
		glm::ivec3 D1 = glm::log2(glm::ivec3(16));
		glm::ivec4 E1 = glm::log2(glm::ivec4(16));

		Error += A0 == A1 ? 0 : 1;
		Error += glm::all(glm::equal(B0, B1)) ? 0 : 1;
		Error += glm::all(glm::equal(C0, C1)) ? 0 : 1;
		Error += glm::all(glm::equal(D0, D1)) ? 0 : 1;
		Error += glm::all(glm::equal(E0, E1)) ? 0 : 1;

		glm::uint64 A2 = glm::log2(glm::uint64(16));
		glm::u64vec1 B2 = glm::log2(glm::u64vec1(16));
		glm::u64vec2 C2 = glm::log2(glm::u64vec2(16));
		glm::u64vec3 D2 = glm::log2(glm::u64vec3(16));
		glm::u64vec4 E2 = glm::log2(glm::u64vec4(16));

		Error += A2 == glm::uint64(4) ? 0 : 1;
		Error += glm::all(glm::equal(B2, glm::u64vec1(4))) ? 0 : 1;
		Error += glm::all(glm::equal(C2, glm::u64vec2(4))) ? 0 : 1;
		Error += glm::all(glm::equal(D2, glm::u64vec3(4))) ? 0 : 1;
		Error += glm::all(glm::equal(E2, glm::u64vec4(4))) ? 0 : 1;

		return Error;
	}
开发者ID:Georgiiliev,项目名称:framework_final,代码行数:36,代码来源:gtc_integer.cpp


注:本文中的B0函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。