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


C# Vector2f.Dot方法代码示例

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


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

示例1: ClipEdge

		private PPolygonPolygonCollider.PWContactedVertex [] ClipEdge(PPolygonPolygonCollider.PWContactedVertex [] clips,
				Vector2f normal, float dist) {
			PPolygonPolygonCollider.PWContactedVertex [] line = new PPolygonPolygonCollider.PWContactedVertex [2];
			int numClips = 0;
			float dist0 = normal.Dot(clips[0].v) - dist;
			float dist1 = normal.Dot(clips[1].v) - dist;
			if (dist0 < 0.0F) {
				line[numClips] = clips[0];
				numClips++;
			}
			if (dist1 < 0.0F) {
				line[numClips] = clips[1];
				numClips++;
			}
			if (numClips == 0)
				return null;
			if (numClips == 2)
				return line;
			int c = 0;
			if (dist0 < 0.0F && dist1 > 0.0F)
				c = 1;
			float d = dist0 / (dist0 - dist1);
			line[1] = new PPolygonPolygonCollider.PWContactedVertex ();
			line[1].v = clips[1].v.Sub(clips[0].v).Clone();
			line[1].v.MulLocal(d);
			line[1].v.AddLocal(clips[0].v);
			line[1].data = clips[c].data;
			return line;
		}
开发者ID:207h2Flogintvg,项目名称:LGame,代码行数:29,代码来源:PPolygonPolygonCollider.cs

示例2: CalcEffectiveMass

		public static float CalcEffectiveMass(PBody b1, PBody b2, Vector2f r1,
				Vector2f r2, Vector2f normal) {
			float rn1 = normal.Dot(r1);
			float rn2 = normal.Dot(r2);
			return 1.0F / (b1.invM + b2.invM + b1.invI
					* ((r1.x * r1.x + r1.y * r1.y) - rn1 * rn1) + b2.invI
					* ((r2.x * r2.x + r2.y * r2.y) - rn2 * rn2));
		}
开发者ID:207h2Flogintvg,项目名称:LGame,代码行数:8,代码来源:PTransformer.cs

示例3: Collide

		public virtual int Collide(PShape s1, PShape s2, PContact[] cs) {
			if (s1._type != PShapeType.CONVEX_SHAPE
					&& s1._type != PShapeType.BOX_SHAPE
					|| s2._type != PShapeType.CONVEX_SHAPE
					&& s2._type != PShapeType.BOX_SHAPE) {
				return 0;
			}
			PConvexPolygonShape p1 = (PConvexPolygonShape) s1;
			PConvexPolygonShape p2 = (PConvexPolygonShape) s2;
			PPolygonPolygonCollider.PWDistanceData  dis1 = GetDistance(p1, p2);
			if (dis1.dist > 0.0F)
				return 0;
			PPolygonPolygonCollider.PWDistanceData  dis2 = GetDistance(p2, p1);
			if (dis2.dist > 0.0F)
				return 0;
			float error = 0.008F;
			int edgeA;
			PConvexPolygonShape pa;
			PConvexPolygonShape pb;
			bool flip;
			if (dis1.dist > dis2.dist + error) {
				pa = p1;
				pb = p2;
				edgeA = dis1.edge;
				flip = false;
			} else {
				pa = p2;
				pb = p1;
				edgeA = dis2.edge;
				flip = true;
			}
			Vector2f normal = pa.nors[edgeA];
			Vector2f tangent = new Vector2f(-normal.y, normal.x);
			Vector2f[] paVers = pa.vers;
			PPolygonPolygonCollider.PWContactedVertex [] cv = GetEdgeOfPotentialCollision(pa, pb, edgeA,
					flip);
			cv = ClipEdge(cv, tangent.Negate(), -tangent.Dot(paVers[edgeA]));
			if (cv == null)
				return 0;
			cv = ClipEdge(cv, tangent,
					tangent.Dot(paVers[(edgeA + 1) % pa.numVertices]));
			if (cv == null)
				return 0;
			Vector2f contactNormal = (flip) ? normal : normal.Negate();
			int numContacts = 0;
			for (int i = 0; i < 2; i++) {
				float dist = normal.Dot(cv[i].v) - normal.Dot(paVers[edgeA]);
				if (dist < 0.0F) {
					PContact c = new PContact();
					c.normal.Set(contactNormal.x, contactNormal.y);
					c.pos.Set(cv[i].v.x, cv[i].v.y);
					c.overlap = dist;
					c.data = cv[i].data;
					c.data.flip = flip;
					cs[numContacts] = c;
					numContacts++;
				}
			}
	
			return numContacts;
		}
开发者ID:207h2Flogintvg,项目名称:LGame,代码行数:61,代码来源:PPolygonPolygonCollider.cs


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