本文整理汇总了C#中System.Line类的典型用法代码示例。如果您正苦于以下问题:C# Line类的具体用法?C# Line怎么用?C# Line使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Line类属于System命名空间,在下文中一共展示了Line类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Impulse
public void Impulse(Line force)
{
var div = force / Mass;
var cross = (CenterOfMass - force.Start).Normalize().Dot(div.Normalize());
DTheta -= div.Length * cross / 3;
Velocity += div * (1 - cross);
}
示例2: OnLoadScene
public override Scene OnLoadScene()
{
this.mEngine.RegisterUpdateHandler(new FPSLogger());
Scene scene = new Scene(1);
scene.Background = new ColorBackground(0.09804f, 0.6274f, 0.8784f);
Random random = new Random(RANDOM_SEED);
for (int i = 0; i < LINE_COUNT; i++)
{
float x1 = (float)(random.NextDouble() * CAMERA_WIDTH);
float x2 = (float)(random.NextDouble() * CAMERA_WIDTH);
float y1 = (float)(random.NextDouble() * CAMERA_HEIGHT);
float y2 = (float)(random.NextDouble() * CAMERA_HEIGHT);
float lineWidth = (float)(random.NextDouble() * 5);
Line line = new Line(x1, y1, x2, y2, lineWidth);
line.SetColor((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble());
scene.getLastChild().attachChild(line);
}
return scene;
}
示例3: UpdateDependencies
public override void UpdateDependencies(double currentTime)
{
base.UpdateDependencies(currentTime);
if (Visible)
{
if (_line == null)
{
_line = new Line();
_circle = new Circle {Radius = Radius};
_circle.AttachTo(this, false);
_line.AttachTo(_circle, false);
_line.RelativePoint1 = new Point3D(0, 0);
_line.RelativePoint2 = new Point3D(Radius, 0);
}
if (!_added)
{
ShapeManager.AddLine(_line);
ShapeManager.AddCircle(_circle);
_added = true;
}
}
if (!Visible && _line != null)
{
ShapeManager.Remove(_line);
ShapeManager.Remove(_circle);
_added = false;
}
}
示例4: DelayedHitCalc
public override RealHitInfo DelayedHitCalc(Line by, HitInfo hit)
{
RealHitInfo realHit = new RealHitInfo();
realHit.HitStuff = Surface;
realHit.Pigment = Pigment;
realHit.Normal = new Line();
realHit.Normal.Start = by.Project(hit.HitDist);
realHit.Normal.Direct.Dx = 0;
realHit.Normal.Direct.Dy = 0;
realHit.Normal.Direct.Dz = 0;
switch (hit.SurfaceIndex)
{
case 0:
Point hitLoc2 = inv.Apply(realHit.Normal.Start);
realHit.Normal.Direct.Dx = hitLoc2.X;
realHit.Normal.Direct.Dy = hitLoc2.Y;
realHit.Normal.Direct.Dz = hitLoc2.Z;
break;
default:
throw new InvalidOperationException("Invalid surface index in hitdata");
}
Vector before = realHit.Normal.Direct;
realHit.Normal.Direct = trans.Apply(realHit.Normal.Direct);
if (realHit.Normal.Direct.Dot(by.Direct) > 0)
{
realHit.Normal.Direct.ScaleSelf(-1.0);
}
return realHit;
}
示例5: Add
/// <summary>
/// Adds string
/// </summary>
/// <param name="format"></param>
/// <param name="args"></param>
public void Add( Color color, string format, params object[] args )
{
Line line = new Line();
line.text = string.Format( format, args );
line.color = color;
linesAccum.Add( line );
}
示例6: UpdateDependencies
public override void UpdateDependencies(double currentTime)
{
base.UpdateDependencies(currentTime);
if (Visible)
{
if (_line == null)
{
_line = new Line();
_line.AttachTo(this, false);
_line.RelativePoint1 = new Point3D(0, 0);
_line.RelativePoint2 = new Point3D(Length * ScaleX, 0);
}
if (!_added)
{
ShapeManager.AddLine(_line);
_added = true;
}
if (Math.Abs(_line.RelativePoint2.X - Length * ScaleX) > Double.Epsilon)
{
_line.RelativePoint2.X = Length;
}
}
if (!Visible && _line != null)
{
ShapeManager.Remove(_line);
_added = false;
}
}
示例7: DataAccess_IOrmModelSingleGet
public void DataAccess_IOrmModelSingleGet()
{
Line line = new Line();
line = (Line)line.Get<Line>(1);
Assert.AreEqual(line.Title, "Lemongrass and Lavender");
}
示例8: DrawLine
public void DrawLine (Line line, ConsoleColor? color = null, LineWidth lineWidth = LineWidth.Single)
{
if (line.IsHorizontal)
DrawHorizontalLine(line.X, line.Y, line.Width, color, lineWidth);
else if (line.IsVertical)
DrawVerticalLine(line.X, line.Y, line.Height, color, lineWidth);
}
示例9: DrawableLine
public DrawableLine()
: base("DrawableLine", Layer.Opaque)
{
line = new Line();
line.StartColor = Color.Yellow;
line.EndColor = Color.Yellow;
}
示例10: ExecuteCommand
public void ExecuteCommand()
{
barDiameter = TryGetBarDiameter("\nŚrednica pręta [mm] : ");
if (!barDiameter.HasValue)
return;
spanStep = TryGetSpanStep("\nRozstaw [mm] : ");
if (!spanStep.HasValue)
return;
barPoint1 = TryGetPoint("\nPokaż pręt 1 : ");
if (!barPoint1.HasValue)
return;
barPoint2 = TryGetPoint("\nPokaż pręt 2 : ", barPoint1);
if (!barPoint2.HasValue)
return;
firstBarLine = GetRoundBarLine(roundValue);
if (TryDisplayBarLadder())
{
string blockName = CreateBlockRecord();
Handle handle = InsertBlock(blockName);
SetXData(handle);
}
else
{
return;
}
}
示例11: GetClosestPoint
public static bool GetClosestPoint(Line line, Vector3F point, out Vector3F closestPointOnLine)
{
float parameter;
GetLineParameter(new LineSegment(line.PointOnLine, line.PointOnLine + line.Direction), point, out parameter);
closestPointOnLine = line.PointOnLine + parameter * line.Direction;
return Vector3F.AreNumericallyEqual(point, closestPointOnLine);
}
示例12: ExplotaAReadOnlyLine
/// <summary>
/// Devuelve una secuencia de ReadOnlyLine explotando la entidad si es necesario.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="secuenciaOriginal"></param>
/// <returns></returns>
public static IEnumerable<ReadOnlyLine> ExplotaAReadOnlyLine(this Entity entidad)
{
if (entidad is ReadOnlyLine)
yield return entidad as ReadOnlyLine;
if (entidad is ReadOnlyPolygon)
{
ReadOnlyPolygon polígono = entidad as ReadOnlyPolygon;
// Devolvemos primero el contorno exterior como una línea cerrada
Line línea = new Line(polígono.Codes);
línea.Points.Add(polígono.Points);
yield return línea;
// Devolvemos cada uno de los huecos que son líneas cerradas
foreach (var hueco in polígono.Holes)
yield return hueco;
}
if (entidad is ReadOnlyComplex)
{
ReadOnlyComplex complejo = entidad as ReadOnlyComplex;
foreach (var subentidad in complejo.Entities)
{
if (subentidad is ReadOnlyLine)
yield return subentidad as ReadOnlyLine;
}
}
yield break;
}
示例13: LerpProjectOnto
///<summary>
///The proportion that, when lerped across the given line, results in the given point.
///If the point is not on the line segment, the result is the closest point on the extended line.
///</summary>
public static double LerpProjectOnto(this Vector2d point, Line line)
{
return line.NearestT(point, false);
/*var b = point - line[0];
var d = line.Delta;
return (b * d) / (d * d);*/
}
示例14: GivenAnOrderDiscount_WhenApplyToNonOrder_ThenShouldReturnZero
public void GivenAnOrderDiscount_WhenApplyToNonOrder_ThenShouldReturnZero()
{
var sut = new OrderDiscount("d", 1);
var line = new Line(new Bike(string.Empty, string.Empty, 1), 1);
Assert.AreEqual(0, sut.Apply(line));
}
示例15: LineIntersection
public void LineIntersection()
{
Line horizontalLine = new Line(new Vector2D(0.0f, 1.0f), new Vector2D(2.0f, 1.0f));
Line verticalLine = new Line(new Vector2D(1.0f, 0.0f), new Vector2D(1.0f, 2.0f));
Assert.IsTrue(horizontalLine.TestIntersection(verticalLine));
Assert.IsTrue(horizontalLine.TestIntersection(horizontalLine));
Assert.IsTrue(verticalLine.TestIntersection(verticalLine));
Line offsetHorizontalLine = new Line(new Vector2D(0.0f, 3.0f), new Vector2D(2.0f, 3.0f));
Assert.IsFalse(offsetHorizontalLine.TestIntersection(horizontalLine));
Line reverseHorizontalLine = new Line(new Vector2D(2.0f, 1.0f), new Vector2D(0.0f, 1.0f));
Line reverseVerticalLine = new Line(new Vector2D(1.0f, 2.0f), new Vector2D(1.0f, 0.0f));
Line reverseOffsetHorizontalLine = new Line(new Vector2D(0.0f, 3.0f), new Vector2D(2.0f, 3.0f));
Assert.IsTrue(reverseHorizontalLine.TestIntersection(reverseVerticalLine));
Assert.IsTrue(reverseHorizontalLine.TestIntersection(verticalLine));
Assert.IsTrue(reverseVerticalLine.TestIntersection(verticalLine));
Assert.IsTrue(reverseVerticalLine.TestIntersection(reverseVerticalLine));
Assert.IsFalse(reverseHorizontalLine.TestIntersection(reverseOffsetHorizontalLine));
Assert.IsFalse(reverseHorizontalLine.TestIntersection(offsetHorizontalLine));
}