本文整理汇总了C#中Vector.Set方法的典型用法代码示例。如果您正苦于以下问题:C# Vector.Set方法的具体用法?C# Vector.Set怎么用?C# Vector.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector
的用法示例。
在下文中一共展示了Vector.Set方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindNormal
/**
* FindNormal
*
* @param point
* @param normal
*/
public override void FindNormal(Point point, Vector normal)
{
normal.Set(Normal.GetX(), Normal.GetY(), Normal.GetZ());
}
示例2: ConvolveCubeMap
//.........这里部分代码省略.........
SumReflectance += Reflectance;
// Reflectance *= Normalizer;
SamplesList.Add( new Vector4D(
SinTheta * CosPhi,
SinTheta * SinPhi,
CosTheta,
Reflectance
) );
}
}
// Normalize samples' reflectance
Vector4D[] Samples = SamplesList.ToArray();
int SamplesCount = Samples.Length;
// float Normalizer = 1.0f / SumReflectance;
float Normalizer = 1.0f / Samples.Length;
for ( int SampleIndex=0; SampleIndex < SamplesCount; SampleIndex++ )
{
Samples[SampleIndex].w *= Normalizer;
}
//*/
// Perform convolution
for ( int FaceIndex=0; FaceIndex < 6; FaceIndex++ )
{
Vector4D[,] CubeFace = new Vector4D[MipCubeSize,MipCubeSize];
MipCubeFaces[FaceIndex] = CubeFace;
switch ( FaceIndex )
{
case 0: // +X
X.Set( 0, 0, -1 );
Y.Set( 0, -1, 0 );
Z.Set( 1, 0, 0 );
break;
case 1: // -X
X.Set( 0, 0, 1 );
Y.Set( 0, -1, 0 );
Z.Set( -1, 0, 0 );
break;
case 2: // +Y
X.Set( 1, 0, 0 );
Y.Set( 0, 0, 1 );
Z.Set( 0, 1, 0 );
break;
case 3: // -Y
X.Set( 1, 0, 0 );
Y.Set( 0, 0, -1 );
Z.Set( 0, -1, 0 );
break;
case 4: // +Z
X.Set( 1, 0, 0 );
Y.Set( 0, -1, 0 );
Z.Set( 0, 0, 1 );
break;
case 5: // -Z
X.Set( -1, 0, 0 );
Y.Set( 0, -1, 0 );
Z.Set( 0, 0, -1 );
break;
}
Vector Up = new Vector( 0, 1, 0 );
Vector T, B;
示例3: Main
static void Main(string[] args)
{
string[] inputs;
int surfaceN = int.Parse(Console.ReadLine()); // the number of points used to draw the surface of Mars.
string outputTest01 = "N(" + surfaceN + ")/";
List<Vector> listLands = new List<Vector>();
for (int i = 0; i < surfaceN; i++)
{
inputs = Console.ReadLine().Split(' ');
int landX = int.Parse(inputs[0]); // X coordinate of a surface point. (0 to 6999)
int landY = int.Parse(inputs[1]); // Y coordinate of a surface point. By linking all the points together in a sequential fashion, you form the surface of Mars.
listLands.Add(new Vector(landX, landY));
outputTest01 += "/(" + landX + "," + landY + ")";
}
Console.Error.WriteLine(outputTest01);
Vector pos = new Vector();
Vector speed = new Vector();
Vector DirDown = new Vector(0, -1);
int speedTarget = 3;
int angleTarget = 0;
// game loop
while (true)
{
inputs = Console.ReadLine().Split(' ');
int X = int.Parse(inputs[0]);
int Y = int.Parse(inputs[1]);
int hSpeed = int.Parse(inputs[2]); // the horizontal speed (in m/s), can be negative.
int vSpeed = int.Parse(inputs[3]); // the vertical speed (in m/s), can be negative.
int fuel = int.Parse(inputs[4]); // the quantity of remaining fuel in liters.
int rotate = int.Parse(inputs[5]); // the rotation angle in degrees (-90 to 90).
int power = int.Parse(inputs[6]); // the thrust power (0 to 4).
// Write an action using Console.WriteLine()
// To debug: Console.Error.WriteLine("Debug messages...");
pos.Set(X, Y);
speed.Set(hSpeed, vSpeed);
angleTarget = 6; //@TEST
CalcAnglePower(power, rotate, fuel, speed, pos, listLands, out speedTarget, out angleTarget);
Console.Error.WriteLine( "rotate(" + (rotate)
+ ")//power(" + (power)
+ "//pos" + pos);
Console.WriteLine(angleTarget + " " + speedTarget); // 2 integers: rotate power. rotate is the desired rotation angle (should be 0 for level 1), power is the desired thrust power (0 to 4).
}
}
示例4: CalcAnglePower
static void CalcAnglePower( int powerCurrent,
int angleCurrent,
int fuelCurrent,
Vector speedCurrent,
Vector posCurrent,
List<Vector> targetLevel,
out int powerTarget, out int angleTarget )
{
Vector speedCurr = new Vector(speedCurrent.X, speedCurrent.Y);
Vector posCurr = new Vector(posCurrent.X, posCurrent.Y);
Vector posTarget = targetLevel[0] + targetLevel[1];
Vector dirUp = (targetLevel[0] - targetLevel[1]).Rotate(90.0f).Normalize();
bool isIn = false;
bool isOverSpeedLanding = false;
posTarget.Set(posTarget.X / 2.0f, posTarget.Y / 2.0f);
bool isCrossOver = false;
float fuelCurr = fuelCurrent;
Console.Error.WriteLine("CalcAngle//powerCurrent(" + (powerCurrent) + ")/angleCurrent(" + angleCurrent + ")");
float speedX = speedCurrent.X, speedY = speedCurrent.Y;
//@ Key = speed each fall, Value = distance from land.
Dictionary<int, int> collectFall = new Dictionary<int, int>();
int seq = 0;
while (posCurr.Y > 0 && fuelCurr > 0 && isCrossOver == false)
{
++seq;
fuelCurr = fuelCurr - powerCurrent;
if (fuelCurr < 0)
{
break;
}
speedY = speedY + ((EpsilonZero((float)Math.Cos(DegToRad * angleCurrent)) * powerCurrent) + SpeedG);
speedX = speedX + (EpsilonZero((float)Math.Cos(DegToRad * (90.0f - angleCurrent))) * powerCurrent);
speedCurr.Set(speedX, speedY);
posCurr.Set(posCurr.X + speedCurr.X, posCurr.Y + speedCurr.Y);
collectFall.Add((int)Math.Round(speedY), (int)Math.Round(posCurr.Y));
Console.Error.WriteLine("CalcAngle(" + (seq.ToString("00")) + ")//angle(" + (angleCurrent) + "," + EpsilonZero((float)Math.Cos(DegToRad * (90.0f - angleCurrent)))
+ ")/speedCurr" + (speedCurr)
+ "/pos" + posCurr
+ "/posTarget" + (posTarget)
+ "/dirUp" + (dirUp) + "");
Vector dirPos = posCurr - posTarget;
if (Vector.Dot(dirUp, dirPos) < 0) //Cross Over Land.
{
if (speedCurr.Y > SpeedMaxLanding)
{
isOverSpeedLanding = false;
}
else
{
isOverSpeedLanding = true;
}
Console.Error.WriteLine("CalcAngle//CrossOver");
isCrossOver = true;
Vector dirIn = targetLevel[1] - targetLevel[0];
Vector dirInPos = posCurr - targetLevel[0];
isIn = Vector.Dot(dirIn, dirInPos) > 0? true : false;
dirIn = targetLevel[0] - targetLevel[1];
dirInPos = posCurr - targetLevel[1];
isIn |= Vector.Dot(dirIn, dirInPos) > 0 ? true : false;
}
}
Console.Error.WriteLine("CalcAnglePower//isIn("+(isIn)+")/fuel("+(fuelCurr)+")/speedCurr.Y("+(speedCurr.Y)+")");
if (false == isOverSpeedLanding)
{
float speedStable = SpeedMaxLanding - 30;
float speedPowerG = (SpeedG + PowerMax);
}
powerTarget = powerCurrent;
angleTarget = angleCurrent;
}
示例5: GetPosTargetLanding
static List<Vector> GetPosTargetLanding(List<Vector> listLand)
{
Vector vReturn = new Vector();
Vector pPrevious = new Vector(float.MinValue, float.MinValue);
List<Vector> sameLevel = new List<Vector>();
foreach (Vector p in listLand)
{
if (p.Y == pPrevious.Y)
{
sameLevel.Add(pPrevious);
sameLevel.Add(p);
break;
}
pPrevious.Set(p.X, p.Y);
}
if (sameLevel.Count() != 2)
{
Console.Error.WriteLine("No Level//(sameLevel.Count() < 1)");
return sameLevel;
}
else
{
vReturn.Set(sameLevel[0].X + sameLevel[1].X * 0.5f, sameLevel[0].Y);
Console.Error.WriteLine("No Level//(sameLevel.Count() < 1)");
return sameLevel;
}
}
示例6: Intersect
/**
* Intersect
*
* @param ray
* @param intersect
* @param Threshold
* @return OctNode
*/
public OctNode Intersect(Ray ray, Point intersect, double Threshold)
{
Vector delta = new Vector(0.0f, 0.0f, 0.0f);
double current = 0.0f;
double t;
int[] facehits = new int[3];
facehits[0] = -1;
facehits[1] = -1;
facehits[2] = -1;
OctNode adjacent = null;
Face[] OFaces = this.OctFaces;
Face MAXXF = OFaces[MAXX];
Face MAXYF = OFaces[MAXY];
Face MAXZF = OFaces[MAXZ];
Face MINXF = OFaces[MINX];
Face MINYF = OFaces[MINY];
Face MINZF = OFaces[MINZ];
if(ray.GetDirection().GetX() != 0.0)
{
t = -(ray.GetOrigin().GetX() - OctFaces[MAXX].GetVert(0).GetX()) / ray.GetDirection().GetX();
if(t > Threshold && t > current)
{
intersect.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, t);
if((intersect.GetY() <= MAXYF.GetVert(0).GetY()) && (intersect.GetY() >= MINYF.GetVert(0).GetY()) &&
(intersect.GetZ() <= MAXZF.GetVert(0).GetZ()) && (intersect.GetZ() >= MINZF.GetVert(0).GetZ()))
{
current = t;
facehits[0] = MAXX;
delta.SetX(Threshold);
}
}
t = -(ray.GetOrigin().GetX() - OctFaces[MINX].GetVert(0).GetX()) / ray.GetDirection().GetX();
if(t > Threshold && t > current)
{
intersect.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, t);
if((intersect.GetY() <= MAXYF.GetVert(0).GetY()) && (intersect.GetY() >= MINYF.GetVert(0).GetY()) &&
(intersect.GetZ() <= MAXZF.GetVert(0).GetZ()) && (intersect.GetZ() >= MINZF.GetVert(0).GetZ()))
{
current = t;
facehits[0] = MINX;
delta.SetX(-Threshold);
}
}
}
if(ray.GetDirection().GetY() != 0.0)
{
t = -(ray.GetOrigin().GetY() - OctFaces[MAXY].GetVert(0).GetY()) / ray.GetDirection().GetY();
if(t > Threshold)
{
if(t > current)
{
intersect.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, t);
if((intersect.GetX() <= MAXXF.GetVert(0).GetX()) && (intersect.GetX() >= MINXF.GetVert(0).GetX()) &&
(intersect.GetZ() <= MAXZF.GetVert(0).GetZ()) && (intersect.GetZ() >= MINZF.GetVert(0).GetZ()))
{
current = t;
facehits[0] = MAXY;
delta.Set(0.0f, Threshold, 0.0f);
}
}
else if(t == current)
{
facehits[1] = MAXY;
delta.SetY(Threshold);
}
}
t = -(ray.GetOrigin().GetY() - OctFaces[MINY].GetVert(0).GetY()) / ray.GetDirection().GetY();
if(t > Threshold)
{
if(t > current)
{
intersect.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, t);
if((intersect.GetX() <= MAXXF.GetVert(0).GetX()) && (intersect.GetX() >= MINXF.GetVert(0).GetX()) &&
(intersect.GetZ() <= MAXZF.GetVert(0).GetZ()) && (intersect.GetZ() >= MINZF.GetVert(0).GetZ()))
{
current = t;
facehits[0] = MINY;
delta.Set(0.0f, -Threshold, 0.0f);
}
}
else if(t == current)
{
facehits[1] = MINY;
delta.SetY(-Threshold);
}
}
}
if(ray.GetDirection().GetZ() != 0.0)
{
t = -(ray.GetOrigin().GetZ() - OctFaces[MAXZ].GetVert(0).GetZ()) / ray.GetDirection().GetZ();
//.........这里部分代码省略.........
示例7: SendPackets
/*
private static void SendPackets(object param) {
ProxyControllerBase controller = (ProxyControllerBase)param;
SetFollowCamPropertiesPacket packet = MakePacket();
Thread.Sleep(10000);
Console.WriteLine("Sending packets");
while (true) {
for (int i = 0; i < 4; i++) {
float xInc = .2f;
float yInc = 0f;
float zInc = 0f;
switch (i) {
case 1: xInc = 0; yInc = .2f; zInc = .022f; break;
case 2: xInc = -.2f; yInc = 0f; break;
case 3: xInc = 0; yInc = -.2f; zInc = -.022f; break;
}
for (int x = 0; x < 320; x++) {
controller.InjectPacket(packet);
Vector3 pos = mCoordinator.Position;
pos.X += xInc;
pos.Y += yInc;
pos.Z += zInc;
mCoordinator.Update(pos, Vector3.Zero, GetRot(pos), Rotation.Zero);
controller.SetCamera();
Thread.Sleep(20);
}
}
}
}
*/
/*
DotNetConfigSource dotnet = new DotNetConfigSource();
ArgvConfigSource arg = new ArgvConfigSource(args);
dotnet.Merge(arg);
arg.AddSwitch("Test", "Test", "t");
string test = arg.Configs["Test"].Get("Test");
string test2 = dotnet.Configs["appSettings"].Get("Test");
Console.WriteLine(test);
mPointStart = Vector.Create("PointStart", 0f, 0f, 0f);
mPointDir = Vector.Create("PointDir", 0f, 0f, 0f);
//Init();
Nui.Init();
Nui.SetAutoPoll(true);
GC.Collect();
Window window = new Window("Test Window");
window.Width = 2000;
window.Height = 1500;
window.TopLeft = new Vector3(0f, -1000f, 750f);
IKinectCursor cursor = new PointCursor();
//IKinectCursor cursor = new SimpleCursor();
//Form = new TestForm(mPlaneTopLeft, mPlaneNormal, mTop, mSide, mPointStart, mPointDir, mIntersection, mW, mH, mX, mY);
//Form form = new KinectMovementForm();
//form.Begin();
Form form = new KinectCursorForm(cursor, window);
ProcessWrangler.BlockingRunForm(form, null);
*/
private static void InitNui()
{
Nui.Init();
Nui.SetAutoPoll(true);
Vector pointEnd = Nui.joint(Nui.Hand_Right);
mPointStart = Nui.joint(Nui.Shoulder_Right);
mPointDir = mPointStart - pointEnd;
mPlaneTopLeft = Vector.Create("PlanePoint", 1f, 1f, 0f);
mPlaneNormal = Vector.Create("PlaneNormal", 0f, 0f, -1f);
mW = Scalar.Create("W", 2f);
mH = Scalar.Create("H", 2f);
Vector vertical = Vector.Create(0f, 1f, 0f); // Vertical
//Calculate the intersection of the plane defined by the point mPlaneTopLeft and the normal mPlaneNormal and the line defined by the point mPointStart and the direction mPointDir.
mIntersection = Nui.intersect(mPlaneTopLeft, Nui.normalize(mPlaneNormal), mPointStart, Nui.normalize(mPointDir));
//Calculate a vector that represents the orientation of the top of the input.
mTop = Nui.scale(Nui.cross(vertical, mPlaneNormal), mW);
//Calculate a vector that represents the orientation of the side of the input.
mSide = Nui.scale(Nui.cross(mPlaneNormal, mTop), mH);
//Calculate the vector (running along the plane) between the top left corner and the point of intersection.
Vector diff = mIntersection - mPlaneTopLeft;
//Project the diff line onto the top and side vectors to get x and y values.
mX = Nui.project(diff, mTop);
mY = Nui.project(diff, mSide);
mX.OnChange += () => {
if (mX.Value > 0 && mX.Value < mW.Value)
Console.WriteLine(mX.Value);
};
mPointStart.Set(1f, 0f, 0f);
//.........这里部分代码省略.........