Skip to content

Commit

Permalink
added matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
8bithunter committed Jun 6, 2024
1 parent a991376 commit 1e8b77c
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 43 deletions.
1 change: 1 addition & 0 deletions Assembly-CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<ItemGroup>
<Compile Include="Assets\Scripts\HeatMap.cs" />
<Compile Include="Assets\Scripts\Setter.cs" />
<Compile Include="Assets\Scripts\Matrix.cs" />
<Compile Include="Assets\Scripts\CursorFollow.cs" />
<Compile Include="Assets\Scripts\Funcs.cs" />
<Compile Include="Assets\Scripts\Scaler.cs" />
Expand Down
23 changes: 22 additions & 1 deletion Assets/Scenes/Damascus.unity
Original file line number Diff line number Diff line change
Expand Up @@ -3255,8 +3255,9 @@ GameObject:
m_Component:
- component: {fileID: 1107804549}
- component: {fileID: 1107804554}
- component: {fileID: 1107804548}
- component: {fileID: 1107804555}
- component: {fileID: 1107804550}
- component: {fileID: 1107804548}
- component: {fileID: 1107804551}
- component: {fileID: 1107804552}
- component: {fileID: 1107804553}
Expand Down Expand Up @@ -3324,6 +3325,7 @@ MonoBehaviour:
dvalue: {fileID: 211295632}
ivalue: {fileID: 1357334183}
startivalue: {fileID: 1864292877}
matrix: {fileID: 0}
--- !u!114 &1107804551
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -3422,6 +3424,25 @@ MonoBehaviour:
realColor: {r: 1, g: 0, b: 0, a: 1}
imagColor: {r: 0, g: 1, b: 0, a: 1}
zeroColor: {r: 0, g: 0, b: 1, a: 1}
--- !u!114 &1107804555
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1107804547}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 91f80fbf37c12434d90e2edbde24c9e6, type: 3}
m_Name:
m_EditorClassIdentifier:
matrixMode: 0
"\xEE":
- 1
- 0
"\u0135":
- 0
- 1
--- !u!1 &1217521754
GameObject:
m_ObjectHideFlags: 0
Expand Down
16 changes: 15 additions & 1 deletion Assets/Scripts/Funcs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public class Funcs : MonoBehaviour

static Complex integrationstart;

public static Matrix matrix;

public void Start()
{
matrix = GetComponent<Matrix>();
}
private void Update()
{
integrationstart = new Complex(starti.position.x, starti.position.y);
Expand All @@ -24,8 +30,16 @@ private void Update()
public static Complex function(Complex unscaledz)
{
Complex z = unscaledz * Scaler.scale;
Complex output;

Complex output = Complex.Sin(z) - 1.5;
if (!matrix.matrixMode)
{
output = Complex.FromPolarCoordinates(z.Real, z.Imaginary);
}
else
{
output = matrix.Transform(z);
}

return (output / Scaler.scale);
}
Expand Down
20 changes: 20 additions & 0 deletions Assets/Scripts/Matrix.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using UnityEngine;

public class Matrix : MonoBehaviour
{
public bool matrixMode = false;

public double[] î = new double[2] {1,
0};

public double[] ĵ = new double[2] {0,
1};

public Complex Transform(Complex value)
{
return new Complex(value.Real * î[0] + value.Imaginary * ĵ[0], value.Real * î[1] + value.Imaginary * ĵ[1]);
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Matrix.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 41 additions & 13 deletions Assets/Scripts/Outputter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
Expand Down Expand Up @@ -26,6 +26,12 @@ public class Outputter : MonoBehaviour
public TMP_Text ivalue;
public TMP_Text startivalue;

public Matrix matrix;

private void Start()
{
matrix = GetComponent<Matrix>();
}
void Update()
{

Expand Down Expand Up @@ -100,22 +106,44 @@ public string FormatComplexNumber(Complex complexNumber, bool dothing)
return "Too Big!";
}
else
{
if (complexNumber.Real >= 0 && complexNumber.Imaginary >= 0)
{
formattedNumber = $"{realPart} + {imagPart}i";
}
else if (complexNumber.Real >= 0 && complexNumber.Imaginary < 0)
{
formattedNumber = $"{realPart} - {imagPart}i";
}
else if (complexNumber.Real < 0 && complexNumber.Imaginary >= 0)
{
if (!matrix.matrixMode)
{
formattedNumber = $"-{realPart} + {imagPart}i";
if (complexNumber.Real >= 0 && complexNumber.Imaginary >= 0)
{
formattedNumber = $"{realPart} + {imagPart}i";
}
else if (complexNumber.Real >= 0 && complexNumber.Imaginary < 0)
{
formattedNumber = $"{realPart} - {imagPart}i";
}
else if (complexNumber.Real < 0 && complexNumber.Imaginary >= 0)
{
formattedNumber = $"-{realPart} + {imagPart}i";
}
else
{
formattedNumber = $"-{realPart} - {imagPart}i";
}
}
else
{
formattedNumber = $"-{realPart} - {imagPart}i";
if (complexNumber.Real >= 0 && complexNumber.Imaginary >= 0)
{
formattedNumber = $"{realPart} î + {imagPart} ĵ";
}
else if (complexNumber.Real >= 0 && complexNumber.Imaginary < 0)
{
formattedNumber = $"{realPart} î - {imagPart} ĵ";
}
else if (complexNumber.Real < 0 && complexNumber.Imaginary >= 0)
{
formattedNumber = $"-{realPart} î + {imagPart} ĵ";
}
else
{
formattedNumber = $"-{realPart} î - {imagPart} ĵ";
}
}
return formattedNumber;
}
Expand Down
22 changes: 17 additions & 5 deletions Assets/Scripts/Scaler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
Expand All @@ -19,6 +19,7 @@ public class Scaler : MonoBehaviour
private float orginalscale2;

private HeatMap heatmap;
private Matrix matrix;

public TMP_Text posr;
public TMP_Text negr;
Expand All @@ -31,6 +32,7 @@ void Start()
orginalscale2 = Unitcircle2.localScale.x;

heatmap = GetComponent<HeatMap>();
matrix = GetComponent<Matrix>();
}

void Update()
Expand All @@ -51,10 +53,20 @@ void Update()
Unitcircle2.localScale = new Vector3(orginalscale2 / (float)scale + (float)(orginalscale2 - orginalscale1 + 11), orginalscale2 / (float)scale + (float)(orginalscale2 - orginalscale1 + 11), orginalscale2 / (float)scale + (float)(orginalscale1 - orginalscale2 + 11));
Unitcircle1.localScale = new Vector3(orginalscale2 / (float)scale + 11, orginalscale2 / (float)scale + 11, orginalscale2 / (float)scale + 11);

posr.text = Math.Round(3 * scale, 1).ToString("0.0");
negr.text = (-Math.Round(3 * scale, 1)).ToString("0.0");
posi.text = Math.Round(3 * scale, 1).ToString("0.0") + "i";
negi.text = (-Math.Round(3 * scale, 1)).ToString("0.0") + "i";
if (!matrix.matrixMode)
{
posr.text = Math.Round(3 * scale, 1).ToString("0.0");
negr.text = (-Math.Round(3 * scale, 1)).ToString("0.0");
posi.text = Math.Round(3 * scale, 1).ToString("0.0") + "i";
negi.text = (-Math.Round(3 * scale, 1)).ToString("0.0") + "i";
}
else
{
posr.text = Math.Round(3 * scale, 1).ToString("0.0") + " î";
negr.text = (-Math.Round(3 * scale, 1)).ToString("0.0") + " î";
posi.text = Math.Round(3 * scale, 1).ToString("0.0") + " ĵ";
negi.text = (-Math.Round(3 * scale, 1)).ToString("0.0") + " ĵ";
}
}

public void BoundedScale(double scaleinput)
Expand Down

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions UserSettings/Layouts/default-2022.dwlt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ MonoBehaviour:
m_MinSize: {x: 300, y: 100}
m_MaxSize: {x: 24288, y: 16192}
vertical: 0
controlID: 40
controlID: 65
--- !u!114 &6
MonoBehaviour:
m_ObjectHideFlags: 52
Expand All @@ -144,7 +144,7 @@ MonoBehaviour:
m_MinSize: {x: 200, y: 100}
m_MaxSize: {x: 16192, y: 16192}
vertical: 1
controlID: 41
controlID: 66
--- !u!114 &7
MonoBehaviour:
m_ObjectHideFlags: 52
Expand Down Expand Up @@ -189,8 +189,8 @@ MonoBehaviour:
y: 0
width: 236
height: 729
m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4001, y: 4021}
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 13}
m_Panes:
- {fileID: 13}
Expand Down Expand Up @@ -270,8 +270,8 @@ MonoBehaviour:
y: 0
width: 462
height: 939
m_MinSize: {x: 276, y: 71}
m_MaxSize: {x: 4001, y: 4021}
m_MinSize: {x: 275, y: 50}
m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 18}
m_Panes:
- {fileID: 18}
Expand Down Expand Up @@ -384,8 +384,8 @@ MonoBehaviour:
m_SceneHierarchy:
m_TreeViewState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_SelectedIDs: fc610000
m_LastClickedID: 25084
m_ExpandedIDs: 1afbffff
m_RenameOverlay:
m_UserAcceptedRename: 0
Expand Down Expand Up @@ -1073,7 +1073,7 @@ MonoBehaviour:
m_ListAreaState:
m_SelectedInstanceIDs:
m_LastClickedInstanceID: 0
m_HadKeyboardFocusLastEvent: 0
m_HadKeyboardFocusLastEvent: 1
m_ExpandedInstanceIDs: c6230000046800001c68000028680000a271000016630000906200007e620000b262000000000000
m_RenameOverlay:
m_UserAcceptedRename: 0
Expand All @@ -1090,7 +1090,7 @@ MonoBehaviour:
m_IsRenaming: 0
m_OriginalEventType: 11
m_IsRenamingFilename: 1
m_ClientGUIView: {fileID: 9}
m_ClientGUIView: {fileID: 10}
m_CreateAssetUtility:
m_EndAction: {fileID: 0}
m_InstanceID: 0
Expand Down

0 comments on commit 1e8b77c

Please sign in to comment.