/// <summary>Add the specified isolated transformation step to the transformation chain if the specified condition returns true.</summary> /// <param name="condition">The condition function that defines whether to apply the specified transformation. It's evaluated in run-time when the /// transformation is going.</param> /// <param name="transformation">The transformation to apply.</param> public TransformationBuilder<TSource, TDestination> IfApplyIsolated(Func<TSource, TDestination, TransformationContext, bool> condition, AbstractTransformation<TSource, TDestination> transformation) { ArgGuard.NotNull(condition, nameof(condition)); ArgGuard.NotNull(transformation, nameof(transformation)); Transformations.Add(new ConditionalTransformer<TSource, TDestination>(condition, transformation.Transform, true)); return this; }
/// <summary>Add the isolated transformation step to the transformation chain.</summary> public TransformationBuilder<TSource, TDestination> ApplyIsolated(AbstractTransformation<TSource, TDestination> transformation, bool? keepInitialDestination = null) { ArgGuard.NotNull(transformation, nameof(transformation)); transformation.IsIsolatedResult = true; transformation.KeepInitialDestination = keepInitialDestination ?? !Configuration.IsolateInitialDestination; Transformations.Add(transformation); return this; }
/// <summary>Applies the transformation <paramref name="action"/> only when <paramref name="condition"/> returns true.</summary> /// <param name="condition">The condition to evaluate.</param> /// <param name="action">The action to execute when condition is true.</param> public TransformationBuilder<TSource, TDestination> IfDo(Func<TSource, TDestination, TransformationContext, bool> condition, Func<TSource, TDestination, TransformationContext, TDestination> action) { ArgGuard.NotNull(condition, nameof(condition)); ArgGuard.NotNull(action, nameof(action)); Transformations.Add(new ConditionalTransformer<TSource, TDestination>(condition, action)); return this; }
/// <summary> /// Clone this scene node. /// </summary> /// <returns>Node copy.</returns> public override Node Clone() { BoundingSphereCullingNode ret = new BoundingSphereCullingNode(); ret.Transformations = Transformations.Clone(); ret.LastBoundingSphere = LastBoundingSphere; ret.Visible = Visible; return(ret); }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.PropertyField(debug); if (!serializedObject.isEditingMultipleObjects) { GUIStyle bold = new GUIStyle(EditorStyles.boldLabel); EditorGUILayout.LabelField( "Attributes (" + attributes.arraySize + ")", bold ); EditorGUI.indentLevel++; EditorGUIUtility.labelWidth = 64; EntityComponent component = serializedObject.targetObject as EntityComponent; for (int i = 0; i < attributes.arraySize; ++i) { SerializedProperty label = attributes.GetArrayElementAtIndex(i).FindPropertyRelative("label"); SerializedProperty state = attributes.GetArrayElementAtIndex(i).FindPropertyRelative("state"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(label.stringValue); component.instances[i].State = EditorGUILayout.Slider(state.floatValue, 0, 1); EditorGUILayout.EndHorizontal(); NormalizedAttribute prototype = component.instances[i].Prototype as NormalizedAttribute; if (prototype.transform != Transformations.Linear()) { EditorGUILayout.BeginHorizontal(); EditorGUI.BeginDisabledGroup(true); EditorGUILayout.LabelField(" (Transformed)"); NormalizedAttribute.TransformedInstance instance = component.instances[i] as NormalizedAttribute.TransformedInstance; EditorGUILayout.Slider(instance.TransformedState, 0, 1); EditorGUI.EndDisabledGroup(); EditorGUILayout.EndHorizontal(); } } } serializedObject.ApplyModifiedProperties(); }
public TaskParameter Transform(ITransformation transformation) { if (transformation == null) { throw new NullReferenceException("The transformation argument was null."); } Transformations.Add(transformation); return(this); }
/// <summary> /// Sets transformation for image loading task /// </summary> /// <returns>The TaskParameter instance for chaining the call.</returns> /// <param name="transformation">Transformation.</param> public TaskParameter Transform(ITransformation transformation) { if (transformation == null) { throw new ArgumentNullException(nameof(transformation)); } Transformations.Add(transformation); return(this); }
/// <summary> /// Sets transformations for image loading task /// </summary> /// <returns>The TaskParameter instance for chaining the call.</returns> /// <param name="transformations">Transformations.</param> public TaskParameter Transform(IEnumerable <ITransformation> transformations) { if (transformations == null) { throw new ArgumentNullException(nameof(transformations)); } Transformations.AddRange(transformations); return(this); }
public override bool OnPickup(Player player) { SoundUtil.PlayVanillaSound(SoundID.NPCDeath7, player); Transformations.EndTransformations(player, true, false); MyPlayer.ModPlayer(player).SSJGTransformation(); MyPlayer.ModPlayer(player).IsTransforming = true; MyPlayer.ModPlayer(player).SSJGAchieved = true; Main.NewText("You feel enveloped in a divine energy."); return(false); }
private void RotateAroundCenter(object sender, EventArgs e) { double angleX = DegreesToRadians((double)numericUpDown10.Value); double angleY = DegreesToRadians((double)numericUpDown11.Value); double angleZ = DegreesToRadians((double)numericUpDown12.Value); var p = CurrentDrawable.Center; CurrentDrawable.Apply(Transformations.RotateAroundPoint(p, angleX, angleY, angleZ)); RefreshScenes(); }
private void AddCell(Coordinate c, byte value) { Numbers.Set2DValue(c, value); Transformations.Set2DValue(c, new TransformInfo { WasNew = true, Destination = Coordinate.Nowhere, PreviousNumber = byte.MaxValue }); }
public MainWindow(double[] data1, double[] data2) { InitializeComponent(); double[] result = new double[data1.Length]; for (int ind = 0; ind < result.Length; ind++) { result[ind] = Transformations.Crosscorrelation(data1, data2, ind); } chart.MouseWheel += chData_MouseWheel; validateSetings(); Control.ControlCollection controls = panelFunctionParams.Controls; double[] args = new double[controls.Count / 2 + 1]; int i = controls.Count / 2; foreach (Control item in controls) { if (item.GetType() == (typeof(TextBox))) { args[i] = Double.Parse(item.Text); i--; } } string chartAreaNum = cbArea.Text; chart.Series.Remove(chart.Series.FindByName(chartAreaNum)); Series series = chart.Series.Add(chartAreaNum); functionName = chartAreaNum; if (chart.ChartAreas.FindByName(chartAreaNum) == null) { chart.ChartAreas.Add(chartAreaNum); cbArea.Items.Add(chartAreaNum); validateSetings(); } series.ChartArea = chartAreaNum; series.ChartType = SeriesChartType.Line; double funValue = 0; for (int j = 0; j < result.Length; j++) { funValue = result[j]; if (!Double.IsInfinity(funValue) && !Double.IsNaN(funValue)) { series.Points.AddXY(j, funValue); } } validateSetings(); }
/// <summary> /// Scales shape relatevile base point. /// </summary> /// <param name="basePoint">The point in the space relatively of wich the shape would be scaled.</param> /// <param name="scale">This value is used to increase(decrease) shape size in all directions.</param> public virtual void Scale(Vertex basePoint, float scale) { var tmpSides = new List <Polygon>(); foreach (var side in sides) { tmpSides.Add(Transformations.ScalePolygon(basePoint, side, scale, scale, scale)); } sides = tmpSides; }
private void Rotate(object sender, EventArgs e) { double rotatingX = DegreesToRadians((double)numericUpDown4.Value); double rotatingY = DegreesToRadians((double)numericUpDown5.Value); double rotatingZ = DegreesToRadians((double)numericUpDown6.Value); CurrentDrawable.Apply(Transformations.RotateX(rotatingX) * Transformations.RotateY(rotatingY) * Transformations.RotateZ(rotatingZ)); RefreshScenes(); }
/// <summary> /// Scales shape relatevile base point. /// </summary> /// <param name="basePoint">The point in the space relatively of wich the shape would be scaled.</param> /// <param name="rotAngleX">The angle to rotate around X axis.</param> /// <param name="rotAngleY">The angle to rotate around Y axis.</param> /// <param name="rotAngleZ">The angle to rotate around Z axis.</param> public virtual void Rotate(Vertex basePoint, double rotAngleX, double rotAngleY, double rotAngleZ) { sides.Clear(); var t = new Transformations(); foreach (var side in initialSides) { sides.Add(t.RotatePolygon(basePoint, side, rotAngleX, rotAngleY, rotAngleZ)); } }
public void InitializeTestData() { _testRotationMatrix = new TransformationMatrix(Transformations.GetRotMatrixZ(Math.PI)); _testTranslationMatrix = new TransformationMatrix(Transformations.GetTranslationMatrix(100, 50, 25)); _testPoint3D = new Point3D(7, 9, 12); _testVector3D = new Vector3D(2, 4, 6); _testPoint = DenseVector.OfArray(new double[] { _testPoint3D.X, _testPoint3D.Y, _testPoint3D.Z, 1 }); _testVector = DenseVector.OfArray(new double[] { _testVector3D.X, _testVector3D.Y, _testVector3D.Z, 0 }); }
public async Task Transformations_Transform_StringToInt() { var transform = Transformations.TryFind <string, int>(); Assert.IsTrue(transform.HasValue); var s = "10"; int i = (int)await transform.Value.Transform(s); Assert.AreEqual(10, i); }
/// <summary> /// Transform a given transformations and return the result matrix. /// </summary> /// <param name="trans">Transformations to transform.</param> /// <returns>Matrix with combined transformations.</returns> public Matrix Transform(Transformations trans) { // build matrix for given transformations Matrix transMatrix = trans.BuildMatrix(); // get our world transformations Matrix worldMatrix = WorldTransformations; // combine and return return(transMatrix * worldMatrix); }
private void ProcessKiExperienceGain(MyPlayer modplayer) { if (Transformations.IsPlayerTransformed(modplayer.player)) { AddKiExperience(0.2f); } if (modplayer.IsFlying) { AddKiExperience(0.1f); } }
public override void ChooseTransformations(Transformations transformations, AssemblyDefinition assembly) { switch (transformations) { case Transformations.ProfileEasy: stringObfClInj = new StringObfuscationClassInjection(reportManager); stringObfClInj.StringCuts(assembly); stringEncryption = new StringEncryption(reportManager); stringEncryption.EncryptStrings(assembly); break; } }
public static Balance GetBalance() { var balance = new Balance(); var stripeBalance = new StripeManager().GetBalance(); if (stripeBalance != null) { balance = Transformations.TransformStripeBalanceToBalance(stripeBalance); } return(balance); }
/// <summary> /// Gets all the input that the servitor has received since the last /// time it got any. /// </summary> /// <returns>The list of the new input</returns> public List <string> Collect() { lock (AllInput) { // It has not changed, because we just looked. Changed = false; // The index when this was triggered int oldIndex = LastIndex; // The last index is now. We just accessed it. LastIndex = AllInput.Count - 1; return(Transformations.Subsequence(AllInput, oldIndex, AllInput.Count)); } }
Vector3[] DoTransforms1(Vector3[] input) { Vector3[] output = new Vector3[input.Length]; for (int i = 0; i < input.Length; i++) { Vector4 temp = input[i]; temp.w = 1; output[i] = Transformations.RotateY(temp, 20.0f); Debug.Log(output[i].ToString("F5")); } return(output); }
private void ScanTransformations() { foreach (var path in Directory.GetFiles(FilesystemPath, "*." + KettleItem.TransformationFileExtension)) { if (!path.EndsWith("#")) { var name = Path.GetFileName(path); var transformation = new Transformation(this, path); Transformations.Add(transformation); Repository.AllTransformations.Add(transformation.Key, transformation); } } }
private void TestUpdate_Click(object sender, EventArgs e) { Indexes.Clear(); indexesLength = 0; CurrentSearchIndex = 0; var transforms = Transformations.Select(x => new TrackedTransformation { Method = x }).ToArray(); int updatedVideos = 0; foreach (var video in Videos) { bool updated = false; foreach (var transformation in transforms) { var transformResult = AdditionalMethods.DoReplacements(video.DisplayDescription, transformation.Method); if (transformResult.Item2) { updated = true; video.DisplayDescription = transformResult.Item4; transformation.TransformCount += transformResult.Item3; } } if (updated) { updatedVideos++; } } UpdateDescriptions.Text = $"Upload {updatedVideos} Changes"; var response = $"Test Updated {updatedVideos} videos\r\n"; foreach (var transform in transforms) { if (transform.Method.Method == AdditionalMethods.StringTransformation.TransformationMethod.Replace) { response += $"Replaced {transform.TransformCount} occurrences of {transform.Method.PrimaryValue} with {transform.Method.SecondaryValue}\r\n"; } else if (transform.Method.Method == AdditionalMethods.StringTransformation.TransformationMethod.Remove) { response += $"Removed {transform.TransformCount} occurrences of {transform.Method.PrimaryValue}\r\n"; } } VideoInformation.Text = NewLineFix(string.Join("\r\n----------\r\n", Videos.Select(x => $"Title: {x.Video.Snippet.Title} ({x.Video.Id})\r\n----------\r\n{x.DisplayDescription}"))); LogMessage("Tested Descriptions update."); LogMessage(response); UpdateDescriptionTextChange(); }
public static void Initialization_with_Coordinates_Results_in_Object_with_Immutable_Coordinates_Properties_List() { CartesianCoordinate localOriginInGlobal = new CartesianCoordinate(3, 2); CartesianCoordinate localAxisXPtInGlobal = new CartesianCoordinate(5, 4); Transformations transformations = new Transformations(localOriginInGlobal, localAxisXPtInGlobal); AngularOffset angularOffset = new AngularOffset(Numbers.Pi / 4); CartesianOffset offset = localOriginInGlobal.OffsetFrom(CartesianCoordinate.Origin()); Assert.AreEqual(localOriginInGlobal, transformations.LocalOrigin); Assert.AreEqual(localAxisXPtInGlobal, transformations.LocalAxisX); Assert.AreEqual(offset, transformations.Displacement); Assert.AreEqual(angularOffset.ToAngle().Degrees, transformations.Rotation.ToAngle().Degrees, Tolerance); }
public static Transformations Instance() { if (_instance == null) { lock (instancelock) { if (_instance == null) { _instance = new Transformations(); } } } return(_instance); }
public Drawable FlashColour(Color4 flashColour, int duration) { Debug.Assert(transformationDelay == 0, @"FlashColour doesn't support Delay() currently"); Color4 startValue = Transformations.FindLast(t => t.Type == TransformationType.Colour)?.EndColour ?? Colour; Transformations.RemoveAll(t => t.Type == TransformationType.Colour); double startTime = Time + transformationDelay; Transformations.Add(new Transformation(flashColour, startValue, startTime, startTime + duration)); return(this); }
public BoneTransformation( Transform bp, Transformations act, List <JointId> betweenJoints, string axis, float bs) { bodyPart = bp; action = act; joints = betweenJoints; aligningAxis = axis; originalSize = bs; originalLocalScale = bp.localScale; }
public virtual Drawable Clone() { Drawable thisNew = (Drawable)MemberwiseClone(); thisNew.internalChildren = new LifetimeList <Drawable>(DepthComparer); Children.ForEach(c => thisNew.internalChildren.Add(c.Clone())); thisNew.transformations = Transformations.Select(t => t.Clone()).ToList(); thisNew.drawInfoBacking.Invalidate(); thisNew.boundingSizeBacking.Invalidate(); return(thisNew); }
public static string TransformationsToString(Transformations transformation) { switch (transformation) { case Transformations.Normalize: return "normalize"; case Transformations.Cumulative: return "cummul"; case Transformations.RelativeDifference: return "rdiff"; case Transformations.Difference: return "diff"; default: return "none"; } }
private static string GetSingleData(string source, string code, DateTime start, Frequencies freq, Transformations trans) { QuandlDownloadRequest requestRawData = new QuandlDownloadRequest(); requestRawData.APIKey = APIK_KEY; requestRawData.Datacode = new Datacode(source, code); requestRawData.Format = FileFormats.JSON; requestRawData.Frequency = freq; requestRawData.Transformation = trans; requestRawData.StartDate = start; requestRawData.EndDate = DateTime.Now; var urlRawData = requestRawData.ToRequestString(); return GetMessage(urlRawData); }
/// <summary> /// Perform a given transformation of the array. /// </summary> /// <returns>Returns the transformed array.</returns> private int[] Transform(int[] solution, Transformations transformation) { int tmp; switch (transformation) { case Transformations.Vertical: for (var i = 0; i < 81; i++) { // If column (i % 9) < 4 swap it: if (i%9 < 4) { tmp = solution[i]; var div9 = Math.Floor((decimal)i/9); var tmpIx = (int) ((9*div9 + 8) - (i - (9*div9))); solution[i] = solution[tmpIx]; solution[tmpIx] = tmp; } } break; case Transformations.MainDiagonal: for (var i = 0; i < 81; i++) { // Upper Main diagonal: row + column < 8 if ((Math.Floor((decimal)i/9) + i%9) < 8) { var mod9 = Math.Floor((decimal)i%9); var div9 = Math.Floor((decimal)i/9); tmp = solution[i]; var tmpIx = (int)((8 - mod9)*9 + 8 - div9); solution[i] = solution[tmpIx]; solution[tmpIx] = tmp; } } break; case Transformations.MinorDiagonal: for (var i = 0; i < 81; i++) { // Upper Minor diagonal: row > column if (Math.Floor((decimal)i/9) > i%9) { var mod9 = Math.Floor((decimal)i%9); var div9 = Math.Floor((decimal)i/9); tmp = solution[i]; var tmpIx = (int)(div9 + mod9*9); solution[i] = solution[tmpIx]; solution[tmpIx] = tmp; } } break; case Transformations.Horizontal: default: for (var i = 0; i < 81; i++) { // Row < 4 if (Math.Floor((decimal)i/9) < 4) { var mod9 = Math.Floor((decimal)i % 9); var div9 = Math.Floor((decimal)i / 9); tmp = solution[i]; var tmpIx = (int)(mod9 + (8 - div9)*9); solution[i] = solution[tmpIx]; solution[tmpIx] = tmp; } } break; } return solution; }
public override void Transform(Transformations.IUnitTransformation transform, TransformFlags flags) { Faces.ForEach(f => f.Transform(transform, flags)); // Handle flip transforms / negative scales var origin = GetOrigin(); if (Faces.All(x => x.Plane.OnPlane(origin) >= 0)) { // All planes are facing inwards - flip them all Faces.ForEach(x => x.Flip()); } base.Transform(transform, flags); }