本文整理汇总了C#中Vector4d类的典型用法代码示例。如果您正苦于以下问题:C# Vector4d类的具体用法?C# Vector4d怎么用?C# Vector4d使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vector4d类属于命名空间,在下文中一共展示了Vector4d类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetVisibility
public static Frustum.VISIBILTY GetVisibility(Vector4d clip, Vector3d2[] b, double f)
{
double o = b[0].x * clip.x + b[0].y * clip.y + b[0].z * clip.z;
bool p = o + clip.w > 0.0;
if ((o * f + clip.w > 0.0) == p)
{
o = b[1].x * clip.x + b[1].y * clip.y + b[1].z * clip.z;
if ((o + clip.w > 0.0) == p && (o * f + clip.w > 0.0) == p)
{
o = b[2].x * clip.x + b[2].y * clip.y + b[2].z * clip.z;
if ((o + clip.w > 0.0) == p && (o * f + clip.w > 0.0) == p)
{
o = b[3].x * clip.x + b[3].y * clip.y + b[3].z * clip.z;
return (o + clip.w > 0.0) == p && (o * f + clip.w > 0.0) == p ?
(p ? Frustum.VISIBILTY.FULLY : Frustum.VISIBILTY.INVISIBLE) :
Frustum.VISIBILTY.PARTIALLY;
}
}
}
return Frustum.VISIBILTY.PARTIALLY;
}
开发者ID:Climberfx,项目名称:Scatterer,代码行数:26,代码来源:SphericalDeformation.cs
示例2: LocationToView
public bool LocationToView(Location location, out PointF point)
{
// Move location to 3D earth
var pos3d = new Vector4d (location.Position, 1);
// Camera model
var m = Matrix4d.Mult (modelViewMatrix, projectionMatrix);
// Project into homogeneous 2D point
var pos2h = Vector4d.Transform (pos3d, m);
// Perform the perspective divide
var pos2 = pos2h / pos2h.W;
// Ignore points behind us
if (pos2h.W < 0) {
point = PointF.Empty;
return false;
}
// Console.WriteLine ("{0} = {1}", "W", pos2h.W);
// Stretch into our view
var fr = videoCameraView.Frame;
point = new PointF (
fr.X + (float)((pos2.X + 1) * 0.5) * fr.Width,
fr.Y + (float)((-pos2.Y + 1) * 0.5) * fr.Height
);
return true;
}
开发者ID:jorik041,项目名称:ARDemo,代码行数:30,代码来源:ARViewController2.cs
示例3: Project
private static bool Project(ref Vector3d world, ref Matrix4d modelviewMatrix, ref Matrix4d projectionMatrix, int[] viewport, out Vector3d screen)
{
Vector4d _in = new Vector4d(world, 1.0);
Vector4d _out = new Vector4d();
Vector4d.Transform(ref _in, ref modelviewMatrix, out _out);
Vector4d.Transform(ref _out, ref projectionMatrix, out _in);
if (_in.W == 0.0)
{
screen = Vector3d.Zero;
return false;
}
_in.X /= _in.W;
_in.Y /= _in.W;
_in.Z /= _in.W;
/* Map x, y and z to range 0-1 */
_in.X = _in.X * 0.5 + 0.5;
_in.Y = _in.Y * 0.5 + 0.5;
_in.Z = _in.Z * 0.5 + 0.5;
/* Map x,y to viewport */
_in.X = _in.X * viewport[2] + viewport[0];
_in.Y = _in.Y * viewport[3] + viewport[1];
screen = new Vector3d(_in);
return true;
}
开发者ID:kskjer,项目名称:SceneNavi,代码行数:30,代码来源:ScreenWorldConversion.cs
示例4: Vector4d
public Vector4d(Vector4d v)
{
x = v.x;
y = v.y;
z = v.z;
w = v.w;
}
开发者ID:kharbechteinn,项目名称:Scatterer,代码行数:7,代码来源:Vector4d.cs
示例5: GetOpenGLPNameInfo
public List<KeyValuePair<string, string>> GetOpenGLPNameInfo()
{
List<KeyValuePair<string, string>> info =
new List<KeyValuePair<string, string>>();
foreach (GetPName pname in Enum.GetValues(typeof(GetPName)))
{
double[] buff = new double[32];
GL.GetDouble(pname, buff);
int last = 0;
for (int i = 0; i < 32; i++)
{
if (buff[i] != 0.0)
{
last = i + 1;
}
}
string str = null;
switch (last)
{
case 0:
str = "0";
break;
case 1:
str = buff[0].ToString();
break;
case 2:
Vector2d v2 = new Vector2d(buff[0], buff[1]);
str = v2.ToString();
break;
case 3:
Vector3d v3 = new Vector3d(buff[0], buff[1], buff[2]);
str = v3.ToString();
break;
case 4:
Vector4d v4 = new Vector4d(buff[0], buff[1], buff[2], buff[3]);
str = v4.ToString();
break;
case 16:
Matrix4d m4 = new Matrix4d(buff[0], buff[1], buff[2], buff[3],
buff[4], buff[5], buff[6], buff[7],
buff[8], buff[9], buff[10], buff[11],
buff[12], buff[13], buff[14], buff[15]);
str = m4.ToString();
break;
default:
StringBuilder sb = new StringBuilder();
for (int i = 0; i < last; i++)
{
sb.Append(buff[i]);
sb.Append(',');
}
str = sb.ToString();
break;
}
info.Add(new KeyValuePair<string, string>(pname.ToString(), str));
}
return info;
}
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:58,代码来源:OpenGLInfo.cs
示例6: Project
// https://gist.github.com/871099/8d37734ba22737c69173c2e44eaa332f9c85bcde
// http://www.opentk.com/node/1892
// http://www.opentk.com/node/1276
// http://www.opentk.com/node/887
// http://mesa3d.org/
/// <summary>
/// Projects a coordinate from world space into screen space.
/// </summary>
/// <param name="coordinate">The coordinate to project</param>
/// <param name="viewport">The viewport dimensions</param>
/// <param name="projection">The projection matrix</param>
/// <param name="modelview">The modelview matrix</param>
/// <returns>The coordinate in screen space.</returns>
public static Coordinate Project(Coordinate coordinate, int[] viewport, Matrix4d projection, Matrix4d modelview)
{
var source = new Vector4d(coordinate.DX, coordinate.DY, coordinate.DZ, 1);
var imed = Vector4d.Transform(source, modelview);
var vector = Vector4d.Transform(imed, projection);
if (Math.Abs(vector.W - 0) < 0.00001) return null;
var result = Vector3d.Divide(vector.Xyz, vector.W);
result.X = viewport[0] + viewport[2] * (result.X + 1) / 2;
result.Y = viewport[1] + viewport[3] * (result.Y + 1) / 2;
result.Z = (result.Z + 1) / 2;
return new Coordinate((decimal) result.X, (decimal) result.Y, (decimal) result.Z);
}
开发者ID:silky,项目名称:sledge,代码行数:25,代码来源:MathFunctions.cs
示例7: Draw
public void Draw(TriMesh front, TriMesh back, Vector3D light)
{
Vector4d light4d = new Vector4d(light.x, light.y, light.z, 0);
Vector3D frontPos = new Vector3D(0.5, 0.5, 0.8);
Vector3D backPos = new Vector3D(0, 0, 0);
GL.Enable(EnableCap.Lighting);
GL.Enable(EnableCap.Light0);
GL.Light(LightName.Light0, LightParameter.Diffuse, Color.White);
GL.Light(LightName.Light0, LightParameter.Position, (Vector4)light4d);
GL.Enable(EnableCap.CullFace);
GL.CullFace(CullFaceMode.Back);
GL.Enable(EnableCap.DepthTest);
GL.DepthFunc(DepthFunction.Lequal);
GL.Clear(ClearBufferMask.DepthBufferBit);
GL.Enable(EnableCap.StencilTest);
GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Replace);
GL.StencilFunc(StencilFunction.Always, 1, 1);
GL.Clear(ClearBufferMask.StencilBufferBit);
GL.MatrixMode(MatrixMode.Modelview);
GL.PushMatrix();
Matrix4d m = Matrix4d.LookAt(light4d.Xyz, Vector3d.Zero, Vector3d.UnitY);
GL.MultMatrix(ref m);
GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Diffuse, Color.Red);
GL.ColorMask(false, false, false, false);
DrawMesh(front, frontPos);
GL.ColorMask(true, true, true, true);
GL.PopMatrix();
GL.StencilFunc(StencilFunction.Equal, 1, 1);
GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Diffuse, Color.Black);
DrawMesh(back, backPos);
GL.StencilFunc(StencilFunction.Equal, 0, 1);
GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Diffuse, Color.CornflowerBlue);
DrawMesh(back, backPos);
GL.Disable(EnableCap.StencilTest);
GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Diffuse, Color.CornflowerBlue);
DrawMesh(front, frontPos);
GL.Material(MaterialFace.FrontAndBack,
MaterialParameter.Diffuse, Color.Red);
DrawMesh(this.sphere, light);
GL.Disable(EnableCap.DepthTest);
}
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:52,代码来源:ShadowDemo.cs
示例8: Unproject
/// <summary>
/// Converts a screen space point into a corresponding point in world space.
/// </summary>
/// <param name="coordinate">The coordinate to project</param>
/// <param name="viewport">The viewport dimensions</param>
/// <param name="projection">The projection matrix</param>
/// <param name="modelview">The modelview matrix</param>
/// <returns>The coordinate in world space.</returns>
public static Coordinate Unproject(Coordinate coordinate, int[] viewport, Matrix4d projection, Matrix4d modelview)
{
var matrix = Matrix4d.Invert(Matrix4d.Mult(modelview, projection));
var source = new Vector4d(
(coordinate.DX - viewport[0]) * 2 / viewport[2] - 1,
(coordinate.DY - viewport[1]) * 2 / viewport[3] - 1,
2 * coordinate.DZ - 1,
1);
var vector = Vector4d.Transform(source, matrix);
if (Math.Abs(vector.W - 0) < 0.00001) return null;
var result = Vector3d.Divide(vector.Xyz, vector.W);
return new Coordinate((decimal) result.X, (decimal) result.Y, (decimal) result.Z);
}
开发者ID:silky,项目名称:sledge,代码行数:21,代码来源:MathFunctions.cs
示例9: Calculate
public List<ChunkedLodTreeFactory.ChunkedLodTreeNode> Calculate(
ChunkedLodTreeFactory.ChunkedLodTreeNode root,
double viewportWidth,
double horizontalFieldOfView,
Vector3d cameraPosition,
double allowedScreenSpaceError,
Vector4d[] frustumPlanes)
{
_frustumPlanes = frustumPlanes;
_allowedScreenSpaceError = allowedScreenSpaceError;
_cameraPosition = cameraPosition;
_visibleNodes = new List<ChunkedLodTreeFactory.ChunkedLodTreeNode>();
_k = viewportWidth / (Math.Tan(horizontalFieldOfView / 2));
CalculateVisibleNodes(root);
return _visibleNodes;
}
开发者ID:smoothdeveloper,项目名称:ProceduralGeneration,代码行数:18,代码来源:ChunkedLod.cs
示例10: GetFrustumPlanes
static public Vector4d[] GetFrustumPlanes(Matrix4x4d mat)
{
//extract frustum planes from a projection matrix
Vector4d[] frustumPlanes = new Vector4d[6];
// Extract the LEFT plane
frustumPlanes[0] = new Vector4d();
frustumPlanes[0].x = mat.m[3,0] + mat.m[0,0];
frustumPlanes[0].y = mat.m[3,1] + mat.m[0,1];
frustumPlanes[0].z = mat.m[3,2] + mat.m[0,2];
frustumPlanes[0].w = mat.m[3,3] + mat.m[0,3];
// Extract the RIGHT plane
frustumPlanes[1] = new Vector4d();
frustumPlanes[1].x = mat.m[3,0] - mat.m[0,0];
frustumPlanes[1].y = mat.m[3,1] - mat.m[0,1];
frustumPlanes[1].z = mat.m[3,2] - mat.m[0,2];
frustumPlanes[1].w = mat.m[3,3] - mat.m[0,3];
// Extract the BOTTOM plane
frustumPlanes[2] = new Vector4d();
frustumPlanes[2].x = mat.m[3,0] + mat.m[1,0];
frustumPlanes[2].y = mat.m[3,1] + mat.m[1,1];
frustumPlanes[2].z = mat.m[3,2] + mat.m[1,2];
frustumPlanes[2].w = mat.m[3,3] + mat.m[1,3];
// Extract the TOP plane
frustumPlanes[3] = new Vector4d();
frustumPlanes[3].x = mat.m[3,0] - mat.m[1,0];
frustumPlanes[3].y = mat.m[3,1] - mat.m[1,1];
frustumPlanes[3].z = mat.m[3,2] - mat.m[1,2];
frustumPlanes[3].w = mat.m[3,3] - mat.m[1,3];
// Extract the NEAR plane
frustumPlanes[4] = new Vector4d();
frustumPlanes[4].x = mat.m[3,0] + mat.m[2,0];
frustumPlanes[4].y = mat.m[3,1] + mat.m[2,1];
frustumPlanes[4].z = mat.m[3,2] + mat.m[2,2];
frustumPlanes[4].w = mat.m[3,3] + mat.m[2,3];
// Extract the FAR plane
frustumPlanes[5] = new Vector4d();
frustumPlanes[5].x = mat.m[3,0] - mat.m[2,0];
frustumPlanes[5].y = mat.m[3,1] - mat.m[2,1];
frustumPlanes[5].z = mat.m[3,2] - mat.m[2,2];
frustumPlanes[5].w = mat.m[3,3] - mat.m[2,3];
return frustumPlanes;
}
开发者ID:kharbechteinn,项目名称:Scatterer,代码行数:44,代码来源:Frustum.cs
示例11: TestVector4Constructor
public static void TestVector4Constructor()
{
Vector4d v0 = new Vector4d();
v0.x.ShouldBe(0); v0.y.ShouldBe(0); v0.z.ShouldBe(0); v0.w.ShouldBe(0);
Vector4d v1 = new Vector4d(5);
v1.x.ShouldBe(5); v1.y.ShouldBe(0); v1.z.ShouldBe(0); v1.w.ShouldBe(0);
Vector4d v2 = new Vector4d(5, 6);
v2.x.ShouldBe(5); v2.y.ShouldBe(6); v2.z.ShouldBe(0); v2.w.ShouldBe(0);
Vector4d v3 = new Vector4d(5, 6, 7);
v3.x.ShouldBe(5); v3.y.ShouldBe(6); v3.z.ShouldBe(7); v3.w.ShouldBe(0);
Vector4d v4 = new Vector4d(5, 6, 7, 8);
v4.x.ShouldBe(5); v4.y.ShouldBe(6); v4.z.ShouldBe(7); v4.w.ShouldBe(8);
Vector4d v5 = new Vector4d(5, 6, 7, 8, 9);
v5.x.ShouldBe(5); v5.y.ShouldBe(6); v5.z.ShouldBe(7); v5.w.ShouldBe(8);
Vector4d v6 = new Vector4d(v4);
v6.ShouldBe(v4);
}
开发者ID:2015SoftwarePrinciples,项目名称:GTKTestWindow,代码行数:23,代码来源:VectorTests.cs
示例12: GetVisibility
static public VISIBILTY GetVisibility(Vector4d[] frustumPlanes, Box3d box)
{
VISIBILTY v0 = GetVisibility(frustumPlanes[0], box);
if (v0 == VISIBILTY.INVISIBLE) {
return VISIBILTY.INVISIBLE;
}
VISIBILTY v1 = GetVisibility(frustumPlanes[1], box);
if (v1 == VISIBILTY.INVISIBLE) {
return VISIBILTY.INVISIBLE;
}
VISIBILTY v2 = GetVisibility(frustumPlanes[2], box);
if (v2 == VISIBILTY.INVISIBLE) {
return VISIBILTY.INVISIBLE;
}
VISIBILTY v3 = GetVisibility(frustumPlanes[3], box);
if (v3 == VISIBILTY.INVISIBLE) {
return VISIBILTY.INVISIBLE;
}
VISIBILTY v4 = GetVisibility(frustumPlanes[4], box);
if (v4 == VISIBILTY.INVISIBLE) {
return VISIBILTY.INVISIBLE;
}
if (v0 == VISIBILTY.FULLY && v1 == VISIBILTY.FULLY &&
v2 == VISIBILTY.FULLY && v3 == VISIBILTY.FULLY &&
v4 == VISIBILTY.FULLY)
{
return VISIBILTY.FULLY;
}
return VISIBILTY.PARTIALLY;
}
开发者ID:kharbechteinn,项目名称:Scatterer,代码行数:37,代码来源:Frustum.cs
示例13: Unproject
/// <summary>
/// Projects a 2d screenspace coordinate to world coordinates.
/// </summary>
public static Vector3d Unproject(Vector3d Point, Matrix4d View, Matrix4d Proj)
{
Matrix4d ma = Matrix4d.Mult(View, Proj);
Matrix4d ima = Matrix4d.Invert(ma);
Vector4d coord = new Vector4d(Point.X, Point.Y, Point.Z, 1.0);
Vector4d res = Vector4d.Transform(coord, ima);
return new Vector3d(res.X / res.W, res.Y / res.W, res.Z / res.W);
}
开发者ID:dzamkov,项目名称:MineViewer,代码行数:11,代码来源:Window.cs
示例14: TransformPlaneToIndices
private Vector4d TransformPlaneToIndices(Vector4d plane)
{
Vector4d newPlane = new Vector4d();
newPlane.x = plane.x * elementSize;
newPlane.y = plane.y * elementSize;
newPlane.z = plane.z * elementSize;
newPlane.w = plane.w + plane.x * lowerRightCorner.x + plane.y * lowerRightCorner.y + plane.z * lowerRightCorner.z;
return newPlane;
}
开发者ID:boniboni,项目名称:Ferram-Aerospace-Research,代码行数:10,代码来源:VehicleVoxel.cs
示例15: CalculateEquationOfPlane
private Vector4d CalculateEquationOfPlane(Vector3d pt1, Vector3d pt2, Vector3d pt3)
{
Vector3d p1p2 = pt2 - pt1;
Vector3d p1p3 = pt3 - pt1;
Vector3d tmp = Vector3d.Cross(p1p2, p1p3);
Vector4d result = new Vector4d(tmp.x, tmp.y, tmp.z);
result.w = -(pt1.x * result.x + pt1.y * result.y + pt1.z * result.z);
return result;
}
开发者ID:boniboni,项目名称:Ferram-Aerospace-Research,代码行数:13,代码来源:VehicleVoxel.cs
示例16: CalculateEquationOfPlaneInIndices
private Vector4d CalculateEquationOfPlaneInIndices(Vector3d pt1, Vector3d pt2, Vector3d pt3)
{
Vector3d p1p2 = pt2 - pt1;
Vector3d p1p3 = pt3 - pt1;
Vector3d tmp = Vector3d.Cross(p1p2, p1p3);
Vector4d result = new Vector4d(tmp.x, tmp.y, tmp.z);
result.w = result.x * (lowerRightCorner.x - pt1.x) + result.y * (lowerRightCorner.y - pt1.y) + result.z * (lowerRightCorner.z - pt1.z);
result.w *= invElementSize;
return result;
}
开发者ID:boniboni,项目名称:Ferram-Aerospace-Research,代码行数:14,代码来源:VehicleVoxel.cs
示例17: Overlaps
/// <summary>Get whether this <see cref="Box4d"/> inclusively intersects with the <see cref="Vector4d"/>.</summary>
public bool Overlaps( ref Vector4d point)
{
return point.X >= Min.X && point.X <= Max.X && point.Y >= Min.Y && point.Y <= Max.Y && point.Z >= Min.Z && point.Z <= Max.Z && point.W >= Min.W && point.W <= Max.W ;
}
开发者ID:Burton-Radons,项目名称:Alexandria,代码行数:5,代码来源:Box1.cs
示例18: Random
/// <summary>Get a random position within the box.</summary>
public void Random(Random rng , out Vector4d result)
{
result.X = (Double)(rng.NextDouble() * (Max.X - Min.X) + Min.X);
result.Y = (Double)(rng.NextDouble() * (Max.Y - Min.Y) + Min.Y);
result.Z = (Double)(rng.NextDouble() * (Max.Z - Min.Z) + Min.Z);
result.W = (Double)(rng.NextDouble() * (Max.W - Min.W) + Min.W);
return;
}
开发者ID:Burton-Radons,项目名称:Alexandria,代码行数:9,代码来源:Box1.cs
示例19: Intersect
/// <summary>Get the intersection type between this box and the point.</summary>
public Containment Intersect( ref Vector4d point)
{
// Most points should be outside, so check that first.
if ( point.X < Min.X || point.X > Max.X || point.Y < Min.Y || point.Y > Max.Y || point.Z < Min.Z || point.Z > Max.Z || point.W < Min.W || point.W > Max.W )
return Containment.Disjoint;
// Now check for boundaries, which will usually be cut short on the first axis.
if ( (point.X == Min.X || point.X == Max.X) && (point.Y == Min.Y || point.Y == Max.Y) && (point.Z == Min.Z || point.Z == Max.Z) && (point.W == Min.W || point.W == Max.W) )
return Containment.Intersects;
return Containment.Contains;
}
开发者ID:Burton-Radons,项目名称:Alexandria,代码行数:11,代码来源:Box1.cs
示例20: NearestPointTo
/// <summary>Get the nearest point between this <see cref="Box4d"/> and a <see cref="Vector4d"/>. If the <see cref="Vector4d"/> is inside this <see cref="Box4d"/>, it is returned untouched.</summary>
public void NearestPointTo( ref Vector4d point , out Vector4d result)
{
Containment containment = Intersect(ref point);
if(containment != Containment.Disjoint)
result = point;
else
point.Clamp(ref Min, ref Max, out result);
return;
}
开发者ID:Burton-Radons,项目名称:Alexandria,代码行数:10,代码来源:Box1.cs
注:本文中的Vector4d类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论