本文整理汇总了C#中Curve类的典型用法代码示例。如果您正苦于以下问题:C# Curve类的具体用法?C# Curve怎么用?C# Curve使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Curve类属于命名空间,在下文中一共展示了Curve类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MustFlipCurve
/// <summary>
/// Checks if curve is flipped to a plane.
/// </summary>
/// <param name="plane">
/// The plane.
/// </param>
/// <param name="curve">
/// The curve.
/// </param>
/// <returns>
/// True if the curve is flipped to the plane, false otherwise.
/// </returns>
public static bool MustFlipCurve(Plane plane, Curve curve)
{
XYZ xVector = null;
XYZ yVector = null;
if (curve is Arc)
{
Arc arc = curve as Arc;
xVector = arc.XDirection;
yVector = arc.YDirection;
}
else if (curve is Ellipse)
{
Ellipse ellipse = curve as Ellipse;
xVector = ellipse.XDirection;
yVector = ellipse.YDirection;
}
else
return false;
List<double> realListX = ConvertVectorToLocalCoordinates(plane, xVector);
List<double> realListY = ConvertVectorToLocalCoordinates(plane, yVector);
double dot = realListY[0] * (-realListX[1]) + realListY[1] * (realListX[0]);
if (dot < -MathUtil.Eps())
return true;
return false;
}
示例2: CreateFCurve
public Curve CreateFCurve()
{
Curve fCurve = new Curve(DefaultValue);
fCurve.AddKeyframe(new Keyframe(1f, 0f));
fCurve.AddKeyframe(new Keyframe(6f, 10f));
return fCurve;
}
示例3: Map
public void Map()
{
// Arrange
var start = new DateTime(2010, 1, 1);
var end = DateUtility.MaxDate;
var range = new DateRange(start, end);
var id = new MDM.Contracts.NexusId { SystemName = "Test", Identifier = "A" };
var contractDetails = new MDM.Contracts.CurveDetails();
var contract = new MDM.Contracts.Curve
{
Identifiers = new MDM.Contracts.NexusIdList { id },
Details = contractDetails,
Nexus = new MDM.Contracts.SystemData { StartDate = start, EndDate = end }
};
// NB Don't assign validity here, want to prove SUT sets it
var details = new Curve();
var mapping = new CurveMapping();
var mappingEngine = new Mock<IMappingEngine>();
mappingEngine.Setup(x => x.Map<MDM.Contracts.NexusId, CurveMapping>(id)).Returns(mapping);
mappingEngine.Setup(x => x.Map<MDM.Contracts.CurveDetails, Curve>(contractDetails)).Returns(details);
var mapper = new CurveMapper(mappingEngine.Object);
// Act
var candidate = mapper.Map(contract);
// Assert
//Assert.AreEqual(1, candidate.Details.Count, "Detail count differs");
Assert.AreEqual(1, candidate.Mappings.Count, "Mapping count differs");
Check(range, details.Validity, "Validity differs");
}
示例4: AddCurve
public void AddCurve(Curve c)
{
curveList.Add(c);
maxx = 0;
minx = 0;
maxy = 0;
miny = Double.MaxValue;
foreach (Curve cu in curveList)
{
foreach (double a in cu.Data)
{
if (a > maxy)
maxy = a;
if (a < miny)
miny = a;
}
if (cu.Data.Length > maxx)
maxx = cu.Data.Length;
maxy = Math.Ceiling(maxy);
}
foreach (Curve cu in curveList)
{
EnsureCurve(cu);
}
panel1.Invalidate();
}
示例5: Add
public CurveDetail Add(CurveDetail parent)
{
// there is no hierarchy so parent can be safely ignored
CurveDetail detail = new CurveDetail();
detail.Default(Context.UserName);
Curve curve = new Curve();
curve.Default(Context.UserName);
if (Context.Curves.Local.Count() > 0)
{
curve.CurveID = Context.Curves.Local.Max(x => x.CurveID) + 1;
}
else
{
curve.CurveID = 1;
}
detail.Curve = curve;
detail.CurveID = curve.CurveID;
detail.Name = "Curve Name";
Context.Curves.Add(curve);
Context.CurveDetails.Add(detail);
return detail;
}
示例6: SeaShellEffect
public SeaShellEffect()
{
m_hueSaturationEffect = new HueSaturationEffect() { Saturation = 0.6 -1 };
m_vibranceEffect = new VibranceEffect() { Level = .6 };
m_splitToningEffect = new SplitToneEffect
{
ShadowsHue = 230,
ShadowsSaturation = 37,
HighlightsHue = 50,
HighlightsSaturation = 20
};
var globalCurve = new Curve(CurveInterpolation.Linear, new[]
{
new Point(0, 10),
new Point(32, 68),
new Point(64, 119),
new Point(96, 158),
new Point(128, 187),
new Point(160, 209),
new Point(192, 226),
new Point(255, 248)
});
var curve = new Curve(CurveInterpolation.Linear, new[]
{
new Point(10, 0),
new Point(32, 27),
new Point(70, 70)
});
var redCurve = globalCurve;
var greenCurve = Curve.Compose(curve, globalCurve, null);
var blueCurve = globalCurve;
var curvesEffect = new CurvesEffect(redCurve, greenCurve, blueCurve);
var colorizationLayerList = new LayerList(
new AdjustmentLayer(LayerStyle.Normal(), new GrayscaleEffect()),
new Layer(LayerStyle.Multiply(), context => new ColorImageSource(context.HintedRenderSize, Color.FromArgb(0xff, 0xff, 0xe6, 0x99)))
);
LayerList.AddRange(
new AdjustmentLayer(LayerStyle.Normal(0.2), context => colorizationLayerList.ToImageProvider(context.BackgroundImage, context.HintedRenderSize, context.HintedRenderSize)),
new AdjustmentLayer(LayerStyle.Normal(), new ContrastEffect(-0.15)),
new AdjustmentLayer(LayerStyle.Normal(), curvesEffect),
new AdjustmentLayer(LayerStyle.Normal(), m_hueSaturationEffect),
new AdjustmentLayer(LayerStyle.Normal(), m_vibranceEffect),
new AdjustmentLayer(LayerStyle.Normal(), m_splitToningEffect)
);
Editors.Add(new RangeEditorViewModel<SeaShellEffect>("SaturationLevel", -1.0, 1.0, this, filter => filter.SaturationLevel, (filter, value) => filter.SaturationLevel = value));
// Editors.Add(new RangeEditorViewModel<SeaShellEffect>("ContrastLevel", -1.0, 1.0, this, filter => filter.ContrastLevel, (filter, value) => filter.ContrastLevel = value));
Editors.Add(new RangeEditorViewModel<SeaShellEffect>("VibranceLevel", 0, 1.0, this, filter => filter.VibranceLevel, (filter, value) => filter.VibranceLevel = value));
Editors.Add(new RangeEditorViewModel<SeaShellEffect>("ShadowsHue", 0, 365, this, filter => filter.ShadowsHue, (filter, value) => filter.ShadowsHue = (int)value));
Editors.Add(new RangeEditorViewModel<SeaShellEffect>("ShadowsSaturation", 0, 100, this, filter => filter.ShadowsSaturation, (filter, value) => filter.ShadowsSaturation = (int)value));
Editors.Add(new RangeEditorViewModel<SeaShellEffect>("HighlightsHue", 0, 365, this, filter => filter.HighlightsHue, (filter, value) => filter.HighlightsHue = (int)value));
Editors.Add(new RangeEditorViewModel<SeaShellEffect>("HighlightsSaturation", 0, 100, this, filter => filter.HighlightsSaturation, (filter, value) => filter.HighlightsSaturation = (int)value));
}
示例7: Clamp
public void Clamp()
{
var c = new Curve<float>();
c.DefaultInterpolator = Interpolators<float>.Linear;
c[0] = 1.0f;
c[10] = 2.0f;
c[20] = 3.0f;
c[30] = 4.0f;
c.Clamp(5, 25);
AssertEqualFloat(1.5f, c[0]);
AssertEqualFloat(2.0f, c[10]);
AssertEqualFloat(3.0f, c[20]);
AssertEqualFloat(3.5f, c[30]);
c.Clamp(10, 20);
AssertEqualFloat(2.0f, c[0]);
AssertEqualFloat(2.0f, c[10]);
AssertEqualFloat(3.0f, c[20]);
AssertEqualFloat(3.0f, c[30]);
c.Clamp(15, 15);
AssertEqualFloat(2.5f, c[0]);
AssertEqualFloat(2.5f, c[10]);
AssertEqualFloat(2.5f, c[20]);
AssertEqualFloat(2.5f, c[30]);
}
示例8: OnDrawGizmosSelected
void OnDrawGizmosSelected()
{
if(start == null || end == null)
{
return;
}
Vector3 s = start.transform.position, e = end.transform.position;
Gizmos.color = new Color(1f, 1f, 1f, 1f);
Gizmos.DrawLine(s, s + a);
Gizmos.DrawLine(e, e + b);
Curve curve = new Curve(s, s + a, e + b, e);
float lenght = curve.lenght;
CurveData ccd = curve.getDataAt(0f);
CurveData ncd;
Gizmos.color = new Color(1f, 0.3f, 0.3f, 1f);
for(int i = 0; i < 20; i++)
{
ncd = curve.getDataAt((i / 20f) * lenght);
Gizmos.DrawLine(ccd.pos, ncd.pos);
ccd = ncd;
}
Gizmos.DrawLine(ccd.pos, e);
}
示例9: Create
/// <summary>
/// Creates an <see cref="ITokenSigner"/> instance which saves public keys to the provided <see cref="IPublicKeyDataProvider"/>
/// </summary>
/// <param name="publicKeyDataProvider">The <see cref="IPublicKeyDataProvider"/> for the local service</param>
/// <param name="curve">The curve to use</param>
/// <param name="keyLifetime">The max time a private key and its tokens may be used for</param>
/// <param name="keyRotationPeriod">How often to switch to signing with a new private key. The difference between this and <paramref name="keyLifetime"/> is the maximum token lifetime.</param>
/// <returns>A new <see cref="ITokenSigner"/></returns>
public static ITokenSigner Create(
IPublicKeyDataProvider publicKeyDataProvider,
Curve curve,
TimeSpan keyLifetime,
TimeSpan keyRotationPeriod
) {
CngAlgorithm algorithm;
switch( curve ) {
case Curve.P521: {
algorithm = CngAlgorithm.ECDsaP521;
break;
}
case Curve.P384: {
algorithm = CngAlgorithm.ECDsaP384;
break;
}
case Curve.P256:
default: {
algorithm = CngAlgorithm.ECDsaP256;
break;
}
}
IPrivateKeyProvider privateKeyProvider = EcDsaPrivateKeyProvider
.Factory
.Create(
publicKeyDataProvider,
keyLifetime,
keyRotationPeriod,
algorithm
);
var tokenSigner = new TokenSigner( privateKeyProvider );
return tokenSigner;
}
示例10: LoadRgbLookupCurves
private static async Task<Curve[]> LoadRgbLookupCurves(string path, double outputGain, int outputOffset)
{
var storageFile = await Package.Current.InstalledLocation.GetFileAsync(path).AsTask().ConfigureAwait(false);
using (var storageFileImageSource = new StorageFileImageSource(storageFile))
using (var renderer = new BitmapRenderer(storageFileImageSource) { OutputOption = OutputOption.PreserveAspectRatio })
using (var tableBitmap = await renderer.RenderAsync().AsTask().ConfigureAwait(false))
{
var redCurve = new Curve();
var greenCurve = new Curve();
var blueCurve = new Curve();
var redValues = new Point[256];
var greenValues = new Point[256];
var blueValues = new Point[256];
var table = tableBitmap.Buffers[0].Buffer.ToArray();
for (int i = 0; i < 256; ++i)
{
redValues[i] = new Point(i,Math.Min(255, Math.Max(0, (int)(table[i * 4 + 2] * outputGain + outputOffset))));
greenValues[i] = new Point(i,Math.Min(255, Math.Max(0, (int)(table[i * 4 + 1] * outputGain + outputOffset))));
blueValues[i] = new Point(i,Math.Min(255, Math.Max(0, (int)(table[i * 4 + 0] * outputGain + outputOffset))));
}
redCurve.Points = redValues;
greenCurve.Points = greenValues;
blueCurve.Points = blueValues;
return new[] { redCurve, greenCurve, blueCurve };
}
}
示例11: AddCurves
internal static void AddCurves(ScenarioGeneratorModel context)
{
DateTime now = context.AsOfDate;
var curve1 = new Curve() { StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
var curveDetail1 = new CurveDetail() { Name = "SWAPSOIS", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
curve1.CurveDetails.Add(curveDetail1);
var curve2 = new Curve() { StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
var curveDetail2 = new CurveDetail() { Name = "SWAPSOISRISK", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
curve2.CurveDetails.Add(curveDetail2);
CurveFamily item = context.CurveFamilies.Where(x => x.Name == "SWAPS").First();
curveDetail1.CurveFamily = item;
curveDetail2.CurveFamily = item;
TargetSystem system = context.TargetSystems.Where(x => x.Name == "Simra").First();
curveDetail1.TargetSystem = system;
curveDetail2.TargetSystem = system;
context.Curves.Add(curve1);
context.Curves.Add(curve2);
context.SaveChanges();
}
示例12: LineSource
public LineSource(Curve SrcPath, String Code, int el_m, int SrcID, Phase_Regime ph)
: base(new double[8]{60, 49, 41, 35, 31, 28, 26, 24}, new Point3d(0,0,0), ph, SrcID)
{
string type = SrcPath.GetUserString("SourceType");
string v = SrcPath.GetUserString("Velocity");
double velocity = double.Parse(v);
double delta = double.Parse(SrcPath.GetUserString("delta"));
if (type == "Aircraft (ANCON derived)")
{
D = new ANCON(delta, velocity);
}
else D = new Simple();
samplespermeter = el_m;
Curve = SrcPath;
//Divide curve up in ~equal length segments.
Samples = Curve.DivideEquidistant(1.0 / (double)samplespermeter);
Level = Utilities.PachTools.DecodeSourcePower(Code);
Power = new double[8];
double PowerMod = Curve.GetLength() / (double)Samples.Length;
for (int oct = 0; oct < 8; oct++) Power[oct] = 1E-12 * Math.Pow(10, .1 * Level[oct]) * PowerMod;
}
示例13: StartAndEnd
public void StartAndEnd () {
var c = new Curve<double>();
c[-2] = 1;
c[7] = 2;
Assert.AreEqual(c.Start, -2);
Assert.AreEqual(c.End, 7);
}
示例14: SingleValue
public void SingleValue () {
var c = new Curve<double>();
c[0] = 5.0;
Assert.AreEqual(5.0, c[-1]);
Assert.AreEqual(5.0, c[0]);
Assert.AreEqual(5.0, c[1]);
}
示例15: OldPosterEffect
public OldPosterEffect()
{
// Curves
var globalCurve = new Curve(CurveInterpolation.NaturalCubicSpline)
{
Points = new[]
{
new Point(0, 0),
new Point(38, 17),
new Point(160, 210),
new Point(231, 250),
new Point(255, 255)
}
};
var overlayFactory = new OverlayFactory(
"ms-appx:///images/Filters_Landscape_Overlay_Poster2.png",
"ms-appx:///images/Filters_Portrait_Overlay_Poster2.png",
"ms-appx:///images/Filters_Square_Overlay_Poster2.png");
LayerList = new LayerList(
new AdjustmentLayer(LayerStyle.Normal(), new GrayscaleEffect(0.54, 0.64, 0.0, -0.1)),
new AdjustmentLayer(LayerStyle.Normal(), new CurvesEffect(globalCurve)),
new Layer(LayerStyle.Multiply(), context => new ColorImageSource(context.BackgroundLayer.ImageSize, Color.FromArgb(255, 255, 167, 151))),
new Layer(LayerStyle.Normal(), context => overlayFactory.CreateAsync(context.BackgroundLayer.ImageSize))
);
}