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


C++ vec3::length方法代码示例

本文整理汇总了C++中vec3::length方法的典型用法代码示例。如果您正苦于以下问题:C++ vec3::length方法的具体用法?C++ vec3::length怎么用?C++ vec3::length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vec3的用法示例。


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

示例1: isFall

bool FallDetection::isFall(vec3 accelData, vec3 gyroData)
{
	float orientation_mag = gyroData.length();
	history[spot] = accelData.length();
	
	char less_one = spot - 1;
	if (less_one == -1){
		less_one = HISTORY_SIZE - 1;
	}
	float change_accel = history[spot] - history[less_one];

	//Happy path: straight, fast, forward/backward fall
	if (orientation_mag >= P_THRESHOLD && change_accel > DELTA_A_THRESHOLD){
		return true;
	}

	//slower/gradual fall, if you try to break your fall
	char last_one = spot + 1;
	if (last_one > HISTORY_SIZE - 1){
		last_one = 0;
	}
	change_accel = history[spot] - history[last_one];
	if (orientation_mag >= P_THRESHOLD && change_accel > DELTA_A_THRESHOLD){
		return true;
	}

	if (++spot >= HISTORY_SIZE){
		spot = 0;
	}
	return false;
}
开发者ID:ngoluuduythai,项目名称:FallDetection,代码行数:31,代码来源:FallDetection.cpp

示例2: acos

double vec3::angle(vec3 v, vec3 w)
{
	double arg = dot(v, w) / (v.length() * w.length());
	if (arg > 1.0) arg = 1.0;
	if (arg < -1.0) arg = -1.0;
	return acos(arg);
}
开发者ID:nemanjaMet,项目名称:openGL,代码行数:7,代码来源:vec3.cpp

示例3: AngleBetween

float AngleBetween(const vec3 &a, const vec3 &b)
{
    float dotProd = a.dotProduct(b);
    float cosine = dotProd / (a.length() * b.length());

    return RadToDeg(acos(cosine));
}
开发者ID:flaming0,项目名称:software-renderer,代码行数:7,代码来源:math_utils.cpp

示例4: cos

/* origin, to rotate about. Returns a rotation matrix.                 */
mat4 mat4::rotation3D(float angle, const vec3& axisOfRotation)
{
	/* Convert angle to radians. */
	float theta = (float)((PI*angle)/180.0);
	
	/* Calculate sine and cosine values */
	float co = cos(theta);
	float si = sin(theta);
	float t = 1.0f - co;
	
	/* Calculate the axis' length and the direction cosines. */
	float axisLen = axisOfRotation.length();
	float a = (axisOfRotation/axisLen)[0];
	float b = (axisOfRotation/axisLen)[1];
	float c = (axisOfRotation/axisLen)[2];
	
	/* Create the rotation matrix. */
	vec4 row1 = vec4(t * a * a + co, t * a * b - si * c, t * a * c + si * b,
		0.0);
	vec4 row2 = vec4(t * a * b + si * c, t * b * b + co, t * b * c - si * a,
		0.0);
	vec4 row3 = vec4(t * a * c - si * b, t * b * c + si * a, t * c * c + co,
		0.0);
	vec4 row4 = vec4(0, 0, 0, 1);
	
	return mat4(row1, row2, row3, row4);
}
开发者ID:zfergus2,项目名称:MeshModeler,代码行数:28,代码来源:mat4.cpp

示例5: if

Camera::Camera(
  ProjectionType projectionType,
  const vec3& position,
  const vec3& dop,
  const vec3& viewUp,
  REAL angle,
  REAL aspect):
  NameableObject(defaultName()),
  timestamp(0)
//[]---------------------------------------------------[]
//|  Constructor                                        |
//[]---------------------------------------------------[]
{
  this->projectionType = projectionType;
  this->position = position;
  distance = dop.length();
  if (distance < MIN_DISTANCE)
    distance = MIN_DISTANCE;
  directionOfProjection = dop * Math::inverse<REAL>(distance);
  focalPoint = position + dop;
  this->viewUp = viewUp;
  if (angle < MIN_ANGLE)
    angle = MIN_ANGLE;
  else if (angle > MAX_ANGLE)
    angle = MAX_ANGLE;
  viewAngle = angle;
  height = 2 * distance * (REAL)tan(Math::toRadians<REAL>(angle) * 0.5);
  aspectRatio = aspect < MIN_ASPECT ? MIN_ASPECT : aspect;
  F = (REAL)0.1;
  B = (REAL)1000.1;
  viewModified = true;
}
开发者ID:marcostx,项目名称:RayTracer2016,代码行数:32,代码来源:Camera.cpp

示例6: refraction

void EnvironmentRender::refraction(vec3 pos, vec3 nor, gchandle tex)
{
  kgmCamera cam;

  vec3 cpos = gr->m_camera->mPos;
  vec3 cdir = gr->m_camera->mDir;
  f32  fov  = gr->m_camera->mFov;
  f32  asp  = gr->m_camera->mAspect;

  cam.set(fov, asp, gr->m_camera->mNear, gr->m_camera->mFar, cpos, cdir, vec3(0, 0, 1));

  kgmGraphics::Options o;

  o.width = 512;
  o.height = 512;

  o.clipping = true;

  vec3 inor = nor;
  inor.normalize();
  inor.invert();
  o.plane[0] = inor.x;
  o.plane[1] = inor.y;
  o.plane[2] = inor.z;
  o.plane[3] = pos.length();

  o.discard = m_discard;

  gc->gcTexTarget(m_target, tex, gctype_tex2d);
  gc->gcSetTarget(m_target);
  gr->render(cam, o);
  gc->gcSetTarget(null);
}
开发者ID:nocs13,项目名称:kgmEngine,代码行数:33,代码来源:EnvironmentRender.cpp

示例7: normalize

vec3 normalize(const vec3 &v)
{
	float n = v.length();
	if (n == 0.0)
		n = FLT_MIN;
	return v * (1.0 / n);
}
开发者ID:love854baby,项目名称:RayTrace,代码行数:7,代码来源:main.cpp

示例8: acos

mat3 get2DRotMat(vec3 normal)
{	
	mat3 make2DMat = mat3(vec3(1,0,0), vec3(0,1,0), vec3(0,0,1));
	vec3 upVect = vec3(0,0,1);
	if (abs(normal[2]) != 1)
	{
		vec3 rotationAxis = (normal ^ upVect).normalize();
		double rotationAngle = acos((double)((normal * upVect))/(normal.length()/upVect.length()));
		make2DMat = getRotationMatrix(rotationAxis, rotationAngle);
	}
	return make2DMat;
}
开发者ID:petercheng00,项目名称:texturePlanes,代码行数:12,代码来源:util.cpp

示例9: listener

void kgmOSL::listener(vec3& pos, vec3& vel, vec3& ort)
{
  float l = vel.length();
  float dirort[6] = {vel.x, vel.y, vel.z, ort.x, ort.y, ort.z};

  position = pos;
  velocity = vel;
  orient   = ort;

  (void)l;
  (void)dirort;
}
开发者ID:nocs13,项目名称:kgmEngine,代码行数:12,代码来源:kgmOSL.cpp

示例10: setRay

void setRay() {
    vert = vec3(0, 1, 0);
    hori = vert ^ dir;

    dir  =  dir.normalize();
    vert = vert.normalize();
    hori = hori.normalize();

    hori = hori * ( dir.length() * Tan(Fangle/2) / (Rw/2) );
    vert = vert * ( dir.length() * Tan(Fangle/2) / (Rh/2) );
    dir  =  dir - Rw/2 * hori + Rh/2 * vert;
    ///cout << dir[0] << ", " << dir[1] << ", " << dir[2] << endl;
}
开发者ID:BazukaOC,项目名称:RayTracingTesting,代码行数:13,代码来源:main.cpp

示例11:

void
tgPose::RotateAxis (vec3 r)
{
  // 	tgQuaternion q2;
  // 	q2.fromEuler(rot.x,rot.y,rot.z);
  // 	q = q2 * q;
  // 	q.normalise();
  tgQuaternion q2;
  float a = r.length ();
  r.normalize ();
  q2.fromAxis (r, a);
  q = q2 * q;
  q.normalise ();
}
开发者ID:HomeBaseDev,项目名称:sandbox,代码行数:14,代码来源:tgPose.cpp

示例12: invalid_argument

ModelObject::ModelObject(const string& obj_path, const vec3& scale, const string& texture_path, const unsigned int tex_unit)
{
	if (!obj_path.empty() && !texture_path.empty() && (scale.length() != 0))
	{
		ApplicationHelper::load_objectfile(obj_path, vertices, uvs, normals);
		if (!vertices.empty() && !uvs.empty() && !normals.empty())
		{
			create_modelobject(vertices, uvs, normals);
			texture_id = ApplicationHelper::load_bmp_texture(texture_path, tex_unit);
			texture_unit = tex_unit;
			scale_vector = scale;
			position = vec3(0.0f, 0.0f, 0.0f);
		}
		else
			throw invalid_argument("The read data as one of vertices, uvs or normals of obj-file is empty.");
	}
	else
		throw invalid_argument("The passed path of obj or texture or the passed scale is empty.");
}
开发者ID:MrMong,项目名称:solar-lunar-eclipse,代码行数:19,代码来源:ModelObject.cpp

示例13: angle

 static float angle(const vec3& a, const vec3& b)
 {
   return acos(vec3::dot(a, b) / (a.length() * b.length()));
 }
开发者ID:foo,项目名称:ii,代码行数:4,代码来源:vec.hpp

示例14: acosf

float vec3::angle(const vec3 &b) const {
    float l = b.length();
    return acosf( dot(b)/l ) / l;
}
开发者ID:0x2c,项目名称:SSE_Math,代码行数:4,代码来源:math3d.cpp

示例15: normalize

 static vec3 normalize (const vec3& input)
 {
     float length = input.length();
     return (length > 0.0f ? input / length : input);
 }
开发者ID:KhronosGroup,项目名称:KTX,代码行数:5,代码来源:vecmath.hpp


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