├── UnityFunctions ├── ProjectSettings │ ├── ProjectVersion.txt │ ├── AudioManager.asset │ ├── InputManager.asset │ ├── NavMeshAreas.asset │ ├── TagManager.asset │ ├── TimeManager.asset │ ├── VFXManager.asset │ ├── EditorSettings.asset │ ├── NetworkManager.asset │ ├── PresetManager.asset │ ├── DynamicsManager.asset │ ├── GraphicsSettings.asset │ ├── Physics2DSettings.asset │ ├── ProjectSettings.asset │ ├── QualitySettings.asset │ ├── ClusterInputManager.asset │ ├── EditorBuildSettings.asset │ └── UnityConnectSettings.asset ├── Assets │ ├── Scenes │ │ ├── AddingVectors.unity │ │ ├── SoftBodyJiggle.unity │ │ ├── ColliderResearch.unity │ │ ├── DiskDiskCollision.unity │ │ ├── DiskSphereCollision.unity │ │ ├── DistributeCircles.unity │ │ ├── PlaneLineCollision.unity │ │ ├── ProjectPointOnPlane.unity │ │ ├── RayCapsuleCollision.unity │ │ ├── RaySphereCollision.unity │ │ ├── SpringFunctionality.unity │ │ ├── CapsuleDiskCollision.unity │ │ ├── ProjectVectorOnPlane.unity │ │ ├── RayTriangleCollision.unity │ │ ├── SphereSphereCollision.unity │ │ ├── TriangleDiskCollision.unity │ │ ├── TriangleLineCollision.unity │ │ ├── CapsuleCapsuleCollision.unity │ │ ├── CapsuleCapsuleResolution.unity │ │ ├── CapsuleSphereCollision.unity │ │ ├── ClosestOnTwoLineSegments.unity │ │ ├── FingerInverseKinematics.unity │ │ ├── HueSaturationLuminance.unity │ │ ├── LineSegmentConeCollision.unity │ │ ├── LineSegmentDiskCollision.unity │ │ ├── TriangleSphereCollision.unity │ │ ├── TriangleTriangleCollision.unity │ │ ├── TwoJoinsInverseKinematics.unity │ │ ├── MiscTests │ │ │ ├── Test2D3DConversion.unity │ │ │ ├── TestComputeRelative.unity │ │ │ ├── TestMoreThan360Rotation.unity │ │ │ ├── TestRotationByTwoVectorsAndAxis.unity │ │ │ ├── Test2D3DConversion.unity.meta │ │ │ ├── TestComputeRelative.unity.meta │ │ │ ├── TestMoreThan360Rotation.unity.meta │ │ │ └── TestRotationByTwoVectorsAndAxis.unity.meta │ │ ├── RelativeRotationDistribution.unity │ │ ├── ThreeJoinsInverseKinematics.unity │ │ ├── AxisAlignedBoundingBoxCollision.unity │ │ ├── SoftBodyJiggle.unity.meta │ │ ├── DistributeCircles.unity.meta │ │ ├── SpringFunctionality.unity.meta │ │ ├── HueSaturationLuminance.unity.meta │ │ ├── AxisAlignedBoundingBoxCollision.unity.meta │ │ ├── AddingVectors.unity.meta │ │ ├── ColliderResearch.unity.meta │ │ ├── DiskDiskCollision.unity.meta │ │ ├── CapsuleDiskCollision.unity.meta │ │ ├── CapsuleSphereCollision.unity.meta │ │ ├── DiskSphereCollision.unity.meta │ │ ├── PlaneLineCollision.unity.meta │ │ ├── ProjectPointOnPlane.unity.meta │ │ ├── ProjectVectorOnPlane.unity.meta │ │ ├── RayCapsuleCollision.unity.meta │ │ ├── RaySphereCollision.unity.meta │ │ ├── RayTriangleCollision.unity.meta │ │ ├── SphereSphereCollision.unity.meta │ │ ├── TriangleDiskCollision.unity.meta │ │ ├── TriangleLineCollision.unity.meta │ │ ├── CapsuleCapsuleCollision.unity.meta │ │ ├── CapsuleCapsuleResolution.unity.meta │ │ ├── ClosestOnTwoLineSegments.unity.meta │ │ ├── LineSegmentConeCollision.unity.meta │ │ ├── LineSegmentDiskCollision.unity.meta │ │ ├── ThreeJoinsInverseKinematics.unity.meta │ │ ├── TriangleSphereCollision.unity.meta │ │ ├── TriangleTriangleCollision.unity.meta │ │ ├── TwoJoinsInverseKinematics.unity.meta │ │ ├── RelativeRotationDistribution.unity.meta │ │ ├── MiscTests.meta │ │ └── FingerInverseKinematics.unity.meta │ ├── Scripts │ │ ├── Properties │ │ │ ├── AssemblyInfo.cs │ │ │ └── AssemblyInfo.cs.meta │ │ ├── Services.meta │ │ ├── Draw2D.md.meta │ │ ├── Main.meta │ │ ├── Utils.meta │ │ ├── Extensions.meta │ │ ├── Properties.meta │ │ ├── Main │ │ │ ├── MiscTests.meta │ │ │ ├── SoftBodyJiggle.cs.meta │ │ │ ├── SpringFunctionality.cs.meta │ │ │ ├── AddingVectors.cs.meta │ │ │ ├── BaseMainScript.cs.meta │ │ │ ├── DiskDiskCollision.cs.meta │ │ │ ├── DistributeCircles.cs.meta │ │ │ ├── CapsuleDiskCollision.cs.meta │ │ │ ├── CapsuleSphereCollision.cs.meta │ │ │ ├── DiskSphereCollision.cs.meta │ │ │ ├── HueSaturationLuminance.cs.meta │ │ │ ├── PlaneLineCollision.cs.meta │ │ │ ├── ProjectPointOnPlane.cs.meta │ │ │ ├── ProjectVectorOnPlane.cs.meta │ │ │ ├── RayCapsuleCollision.cs.meta │ │ │ ├── RaySphereCollision.cs.meta │ │ │ ├── RayTriangleCollision.cs.meta │ │ │ ├── SphereSphereCollision.cs.meta │ │ │ ├── TriangleDiskCollision.cs.meta │ │ │ ├── TriangleLineCollision.cs.meta │ │ │ ├── CapsuleCapsuleCollision.cs.meta │ │ │ ├── CapsuleCapsuleResolution.cs.meta │ │ │ ├── ClosestOnTwoLineSegments.cs.meta │ │ │ ├── ColliderPhysicsResearch.cs.meta │ │ │ ├── LineSegmentConeCollision.cs.meta │ │ │ ├── LineSegmentDiskCollision.cs.meta │ │ │ ├── TriangleSphereCollision.cs.meta │ │ │ ├── TriangleTriangleCollision.cs.meta │ │ │ ├── TwoJoinsInverseKinematics.cs.meta │ │ │ ├── AxisAlignedBoundingBoxCollision.cs.meta │ │ │ ├── MiscTests │ │ │ │ ├── Test2D3DConversion.cs.meta │ │ │ │ ├── TestComputeRelative.cs.meta │ │ │ │ ├── TestMoreThan360Rotation.cs.meta │ │ │ │ ├── TestRotationByTwoVectorsAndAxis.cs.meta │ │ │ │ ├── TestMoreThan360Rotation.cs │ │ │ │ ├── TestRotationByTwoVectorsAndAxis.cs │ │ │ │ ├── TestComputeRelative.cs │ │ │ │ └── Test2D3DConversion.cs │ │ │ ├── RelativeRotationDistribution.cs.meta │ │ │ ├── FingerInverseKinematics.cs.meta │ │ │ ├── ThreeJoinsInverseKinematics.cs.meta │ │ │ ├── SpringFunctionality.cs │ │ │ ├── AxisAlignedBoundingBoxCollision.cs │ │ │ ├── HueSaturationLuminance.cs │ │ │ ├── ProjectPointOnPlane.cs │ │ │ ├── TriangleLineCollision.cs │ │ │ ├── TriangleSphereCollision.cs │ │ │ ├── RaySphereCollision.cs │ │ │ ├── TriangleDiskCollision.cs │ │ │ ├── SoftBodyJiggle.cs │ │ │ ├── RayCapsuleCollision.cs │ │ │ ├── CapsuleSphereCollision.cs │ │ │ ├── RayTriangleCollision.cs │ │ │ ├── TriangleTriangleCollision.cs │ │ │ ├── SphereSphereCollision.cs │ │ │ ├── DiskSphereCollision.cs │ │ │ ├── CapsuleDiskCollision.cs │ │ │ ├── DiskDiskCollision.cs │ │ │ ├── LineSegmentDiskCollision.cs │ │ │ ├── ProjectVectorOnPlane.cs │ │ │ ├── DistributeCircles.cs │ │ │ ├── AddingVectors.cs │ │ │ ├── ColliderPhysicsResearch.cs │ │ │ ├── CapsuleCapsuleCollision.cs │ │ │ ├── LineSegmentConeCollision.cs │ │ │ ├── PlaneLineCollision.cs │ │ │ ├── ClosestOnTwoLineSegments.cs │ │ │ ├── RelativeRotationDistribution.cs │ │ │ ├── FingerInverseKinematics.cs │ │ │ ├── TwoJoinsInverseKinematics.cs │ │ │ ├── ThreeJoinsInverseKinematics.cs │ │ │ ├── CapsuleCapsuleResolution.cs │ │ │ └── BaseMainScript.cs │ │ ├── v2.cs.meta │ │ ├── Extensions │ │ │ ├── TransformExtensions.cs.meta │ │ │ ├── SingleExtensions.cs.meta │ │ │ ├── ColliderExtensions.cs.meta │ │ │ ├── GameObjectExtensions.cs.meta │ │ │ ├── MaterialExtensions.cs.meta │ │ │ ├── QuaternionExtensions.cs.meta │ │ │ ├── Vector2Extensions.cs.meta │ │ │ ├── Vector3Extensions.cs.meta │ │ │ ├── IntExtensions.cs.meta │ │ │ ├── DoubleExtensions.cs.meta │ │ │ ├── GameObjectExtensions.cs │ │ │ ├── TransformExtensions.cs │ │ │ ├── IntExtensions.cs │ │ │ ├── Vector2Extensions.cs │ │ │ ├── MaterialExtensions.cs │ │ │ ├── ColliderExtensions.cs │ │ │ ├── QuaternionExtensions.cs │ │ │ └── DoubleExtensions.cs │ │ ├── Services │ │ │ ├── PendulumPhysicsAgent.cs.meta │ │ │ ├── SoftBodyJiggleAgent.cs.meta │ │ │ ├── PendulumPhysicsAgent.cs │ │ │ └── SoftBodyJiggleAgent.cs │ │ ├── dbg.cs.meta │ │ ├── fun.cs.meta │ │ ├── TimeRange.cs.meta │ │ ├── Utils │ │ │ ├── Noise.cs.meta │ │ │ └── BezierFunc.cs.meta │ │ ├── AngleAxisData.cs.meta │ │ ├── v3.cs.meta │ │ ├── v2.cs │ │ ├── Draw2D.md │ │ ├── dbg.cs │ │ ├── AngleAxisData.cs │ │ ├── TimeRange.cs │ │ └── v3.cs │ ├── Scenes.meta │ └── Scripts.meta ├── packages │ ├── NUnit.2.6.4 │ │ ├── license.txt │ │ ├── NUnit.2.6.4.nupkg │ │ └── lib │ │ │ └── nunit.framework.dll │ └── manifest.json ├── UnityFunctions.sln.DotSettings ├── UnityFunctions.sln └── Logs │ └── Packages-Update.log ├── UnityFunctionsTests ├── Libs │ ├── UnityEditor.dll │ └── UnityEngine.dll ├── bin │ └── Debug │ │ ├── UnityEngine.dll │ │ ├── Assembly-CSharp.dll │ │ ├── Assembly-CSharp.pdb │ │ ├── nunit.framework.dll │ │ ├── UnityFunctionsTests.dll │ │ └── UnityFunctionsTests.pdb ├── packages.config ├── Properties │ └── AssemblyInfo.cs └── IntersectionTests.cs ├── .gitignore └── README.md /UnityFunctions/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2018.3.0f2 2 | -------------------------------------------------------------------------------- /UnityFunctionsTests/Libs/UnityEditor.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctionsTests/Libs/UnityEditor.dll -------------------------------------------------------------------------------- /UnityFunctionsTests/Libs/UnityEngine.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctionsTests/Libs/UnityEngine.dll -------------------------------------------------------------------------------- /UnityFunctionsTests/bin/Debug/UnityEngine.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctionsTests/bin/Debug/UnityEngine.dll -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/AddingVectors.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/AddingVectors.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/SoftBodyJiggle.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/SoftBodyJiggle.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: InternalsVisibleTo("UnityFunctionsTests")] -------------------------------------------------------------------------------- /UnityFunctions/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /UnityFunctions/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /UnityFunctions/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /UnityFunctions/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /UnityFunctions/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /UnityFunctions/ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/ProjectSettings/VFXManager.asset -------------------------------------------------------------------------------- /UnityFunctions/packages/NUnit.2.6.4/license.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/packages/NUnit.2.6.4/license.txt -------------------------------------------------------------------------------- /UnityFunctionsTests/bin/Debug/Assembly-CSharp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctionsTests/bin/Debug/Assembly-CSharp.dll -------------------------------------------------------------------------------- /UnityFunctionsTests/bin/Debug/Assembly-CSharp.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctionsTests/bin/Debug/Assembly-CSharp.pdb -------------------------------------------------------------------------------- /UnityFunctionsTests/bin/Debug/nunit.framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctionsTests/bin/Debug/nunit.framework.dll -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/ColliderResearch.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/ColliderResearch.unity -------------------------------------------------------------------------------- /UnityFunctions/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /UnityFunctions/ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /UnityFunctions/ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/ProjectSettings/PresetManager.asset -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/DiskDiskCollision.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/DiskDiskCollision.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/DiskSphereCollision.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/DiskSphereCollision.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/DistributeCircles.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/DistributeCircles.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/PlaneLineCollision.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/PlaneLineCollision.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/ProjectPointOnPlane.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/ProjectPointOnPlane.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/RayCapsuleCollision.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/RayCapsuleCollision.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/RaySphereCollision.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/RaySphereCollision.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/SpringFunctionality.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/SpringFunctionality.unity -------------------------------------------------------------------------------- /UnityFunctions/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /UnityFunctions/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /UnityFunctions/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /UnityFunctions/ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /UnityFunctions/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /UnityFunctions/packages/NUnit.2.6.4/NUnit.2.6.4.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/packages/NUnit.2.6.4/NUnit.2.6.4.nupkg -------------------------------------------------------------------------------- /UnityFunctionsTests/bin/Debug/UnityFunctionsTests.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctionsTests/bin/Debug/UnityFunctionsTests.dll -------------------------------------------------------------------------------- /UnityFunctionsTests/bin/Debug/UnityFunctionsTests.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctionsTests/bin/Debug/UnityFunctionsTests.pdb -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/CapsuleDiskCollision.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/CapsuleDiskCollision.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/ProjectVectorOnPlane.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/ProjectVectorOnPlane.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/RayTriangleCollision.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/RayTriangleCollision.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/SphereSphereCollision.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/SphereSphereCollision.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/TriangleDiskCollision.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/TriangleDiskCollision.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/TriangleLineCollision.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/TriangleLineCollision.unity -------------------------------------------------------------------------------- /UnityFunctions/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /UnityFunctions/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /UnityFunctionsTests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/CapsuleCapsuleCollision.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/CapsuleCapsuleCollision.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/CapsuleCapsuleResolution.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/CapsuleCapsuleResolution.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/CapsuleSphereCollision.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/CapsuleSphereCollision.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/ClosestOnTwoLineSegments.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/ClosestOnTwoLineSegments.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/FingerInverseKinematics.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/FingerInverseKinematics.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/HueSaturationLuminance.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/HueSaturationLuminance.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/LineSegmentConeCollision.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/LineSegmentConeCollision.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/LineSegmentDiskCollision.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/LineSegmentDiskCollision.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/TriangleSphereCollision.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/TriangleSphereCollision.unity -------------------------------------------------------------------------------- /UnityFunctions/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /UnityFunctions/packages/NUnit.2.6.4/lib/nunit.framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/packages/NUnit.2.6.4/lib/nunit.framework.dll -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/TriangleTriangleCollision.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/TriangleTriangleCollision.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/TwoJoinsInverseKinematics.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/TwoJoinsInverseKinematics.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/MiscTests/Test2D3DConversion.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/MiscTests/Test2D3DConversion.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/MiscTests/TestComputeRelative.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/MiscTests/TestComputeRelative.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/RelativeRotationDistribution.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/RelativeRotationDistribution.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/ThreeJoinsInverseKinematics.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/ThreeJoinsInverseKinematics.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/AxisAlignedBoundingBoxCollision.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/AxisAlignedBoundingBoxCollision.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/MiscTests/TestMoreThan360Rotation.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/MiscTests/TestMoreThan360Rotation.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/MiscTests/TestRotationByTwoVectorsAndAxis.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vbodurov/unity-functions/HEAD/UnityFunctions/Assets/Scenes/MiscTests/TestRotationByTwoVectorsAndAxis.unity -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/SoftBodyJiggle.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7ebec1415c077a498271350d2c07dec 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/DistributeCircles.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9172c8da8a6b8a248a27963e5e48702d 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/SpringFunctionality.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21fa64162634b5c42ba381dc08d4f537 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/HueSaturationLuminance.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da216e504de2e874fb61649d283c0638 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Services.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2279aa3ebab3f53489ed72a68f7f5284 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Draw2D.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e570f51ba435d3943a6db6b5e1e827d9 3 | timeCreated: 1471764521 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/AxisAlignedBoundingBoxCollision.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fe70ba31d29c8ba4db6e285151cb0284 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/AddingVectors.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 78f7075c91676f040ab8dca3772fad35 3 | timeCreated: 1479578824 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/ColliderResearch.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bbfccdca3ae1c2746b2ecb59dc0e37b4 3 | timeCreated: 1502044432 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/DiskDiskCollision.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aba66c7ed044d414cb0939e8aa247980 3 | timeCreated: 1471907848 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/CapsuleDiskCollision.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 645a5faef67202f4a8d43046081ded8f 3 | timeCreated: 1471898202 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/CapsuleSphereCollision.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f23ada4d991de6244851b1bc50b9ceac 3 | timeCreated: 1471864962 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/DiskSphereCollision.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b38545d2c5688e24c90453342e4ff6de 3 | timeCreated: 1481655887 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/PlaneLineCollision.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c1fa8cb87d4d6da49acbc525ecb3757b 3 | timeCreated: 1478356851 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/ProjectPointOnPlane.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d759df6bcb7ac6a4b9d03d6593adf5fe 3 | timeCreated: 1471595530 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/ProjectVectorOnPlane.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e5f8cff7b36b2364a899b83f33f96e20 3 | timeCreated: 1472340861 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/RayCapsuleCollision.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9fd7fe8a15c55a24fbe4f387fcede6df 3 | timeCreated: 1475981576 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/RaySphereCollision.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8c1f6edc0993430448461f449afffd68 3 | timeCreated: 1471899712 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/RayTriangleCollision.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76592864332d582478811b6ad648c881 3 | timeCreated: 1471602930 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/SphereSphereCollision.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7598bd1485570644fb3a9b6fc5c71d42 3 | timeCreated: 1508041335 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/TriangleDiskCollision.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce1201dc80e3c5b4eacb514f1d201bf4 3 | timeCreated: 1471695730 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/TriangleLineCollision.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 75feda19f3f35074f8d467876c02c5f4 3 | timeCreated: 1471694120 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ed2b796ff16e6e419719da6048e238c 3 | folderAsset: yes 4 | timeCreated: 1471595478 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/CapsuleCapsuleCollision.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 17da877c5aadb244eb716fe39f7ef448 3 | timeCreated: 1471769114 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/CapsuleCapsuleResolution.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87736220553649f4289db9797d207cdc 3 | timeCreated: 1496965341 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/ClosestOnTwoLineSegments.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 07a481440c4f68c4eb1800278141df2c 3 | timeCreated: 1486111703 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/LineSegmentConeCollision.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c6d69383c3c046b4782653ecd997c43c 3 | timeCreated: 1489011062 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/LineSegmentDiskCollision.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0db100529da17b4a9cc9deaf88475c1 3 | timeCreated: 1476218214 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/ThreeJoinsInverseKinematics.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cef2b40a168ec884da7b4b62d412a6f7 3 | timeCreated: 1500431474 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/TriangleSphereCollision.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f905b357d852d440a0848d209e43b32 3 | timeCreated: 1471755058 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/TriangleTriangleCollision.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4c2e2143d4deed048850f3e52c45afe4 3 | timeCreated: 1471659484 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/TwoJoinsInverseKinematics.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eefb9bf54fa891d49ad3a8745bb002c0 3 | timeCreated: 1500777445 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e6fbbae6719527d4fb8f19e27b41bda1 3 | folderAsset: yes 4 | timeCreated: 1471594999 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/MiscTests/Test2D3DConversion.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4ea94ced53892e5428e1de2824d21f31 3 | timeCreated: 1473658657 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/MiscTests/TestComputeRelative.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa672e327680c9a4681e167231e9d2af 3 | timeCreated: 1473423133 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/RelativeRotationDistribution.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3cda3d97ea47fe3449ed1be84e847cff 3 | timeCreated: 1500833087 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6bb0ec64711130f43b9d1ea69d8a5c3d 3 | folderAsset: yes 4 | timeCreated: 1471755162 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Utils.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 28496ca9636058a41848acf81e3d1839 3 | folderAsset: yes 4 | timeCreated: 1473586460 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/MiscTests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3525efc5a67e4f1449487a22a3025428 3 | folderAsset: yes 4 | timeCreated: 1473423098 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/MiscTests/TestMoreThan360Rotation.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa3eb1eba63518942a597a4be6e1bcee 3 | timeCreated: 1474552050 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Extensions.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8861041cce4e9be48a9abfc66f25a1b3 3 | folderAsset: yes 4 | timeCreated: 1471600136 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Properties.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d89debbdad1200945ba49c24923caab3 3 | folderAsset: yes 4 | timeCreated: 1473733103 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/MiscTests/TestRotationByTwoVectorsAndAxis.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: efae9d6bd885043408ee798b954a6cea 3 | timeCreated: 1474614377 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/MiscTests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: af8f9aeadfe7aca41b5e780ebb3f5dc5 3 | folderAsset: yes 4 | timeCreated: 1473423146 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scenes/FingerInverseKinematics.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3197655895b0a3f44906afc48a39f506 3 | timeCreated: 1527674928 4 | licenseType: Pro 5 | DefaultImporter: 6 | externalObjects: {} 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/v2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b2064de99e504cd49a181fc7973270f9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/SoftBodyJiggle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c4eb3acb7edb37e41a523171fed3976c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/SpringFunctionality.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6d37c51c1c165c0409bcfde75edbcafc 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Extensions/TransformExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 331ae0918493d9046864180f3599f3db 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Services/PendulumPhysicsAgent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac9d4c6dc77cbd14e8a8f46a9e8f0433 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Services/SoftBodyJiggleAgent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a25c829908dfed4bb7461670e67e4e9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/dbg.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b35d86c92c1f5114ab23cb4e1866f6db 3 | timeCreated: 1474615755 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/fun.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22c1e9c3794817b46bbf5de50b340f5f 3 | timeCreated: 1471595039 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/TimeRange.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 40cc6f02686cfd040a53ef71237a5b93 3 | timeCreated: 1474552862 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Utils/Noise.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d135c1d1295c28d4894ff8d26783fb17 3 | timeCreated: 1473586460 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/AngleAxisData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21b7d91ab0065b04a89da36cce96b773 3 | timeCreated: 1474614150 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Utils/BezierFunc.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80362213570e28d4b8a7d45281096f11 3 | timeCreated: 1500776734 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/AddingVectors.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8ed40e5dfb687a84b81949d4e010b46f 3 | timeCreated: 1479580469 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/BaseMainScript.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6d682f2ddab833d45aa6dac57ede7833 3 | timeCreated: 1471755162 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/DiskDiskCollision.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8ebd2d48658d4124084736ff5139412b 3 | timeCreated: 1471913132 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/DistributeCircles.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c77f134f830feb04ea2d5b540bcf7ad7 3 | timeCreated: 1481655963 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Extensions/SingleExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c286e585923a5f14589495025f9da011 3 | timeCreated: 1471749945 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/CapsuleDiskCollision.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 490089d3dd341f7498b460fbd9523b7e 3 | timeCreated: 1471897152 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/CapsuleSphereCollision.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91faffe26c501f244be562a7f833c345 3 | timeCreated: 1471865436 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/DiskSphereCollision.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f1e6cc706f34044b83cb689348ff091 3 | timeCreated: 1481655963 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/HueSaturationLuminance.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 097df52a61b4cbe4d85e4a6ee3a459b5 3 | timeCreated: 1481655963 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/PlaneLineCollision.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c908955a4d41ec4caa9f3a9dd12fcc6 3 | timeCreated: 1478357776 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/ProjectPointOnPlane.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02529990e991d0341a4e38fb2d79712c 3 | timeCreated: 1471755162 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/ProjectVectorOnPlane.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 161a64c8521eec04ea3b6a27f5b1ca62 3 | timeCreated: 1472341076 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/RayCapsuleCollision.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a7313a351f585c4890e3e5dceb0796d 3 | timeCreated: 1475982312 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/RaySphereCollision.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 86c8430f5bdb4c845ac49862cc3f5041 3 | timeCreated: 1471900103 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/RayTriangleCollision.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e3e0a11415866f54e8f96c1e29f9aa1b 3 | timeCreated: 1471755162 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/SphereSphereCollision.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d0941bb8c4ae9654b91aa81626130123 3 | timeCreated: 1508041377 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/TriangleDiskCollision.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 98eccad7cca0ff94da0c402e1f243527 3 | timeCreated: 1471755162 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/TriangleLineCollision.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fcfcf77c35bfb3a4f991cd64b5889317 3 | timeCreated: 1471755162 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Properties/AssemblyInfo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c168c496f40e6d4458b12de12e33264f 3 | timeCreated: 1473733103 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Extensions/ColliderExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c18c135021cfd7549a7373295fa4a678 3 | timeCreated: 1502052412 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Extensions/GameObjectExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 52a23e80cb0fb5a409afe3208b2a5b32 3 | timeCreated: 1471600136 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Extensions/MaterialExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a6db6879cae3d3d489e06b10ec820485 3 | timeCreated: 1471600136 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Extensions/QuaternionExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d21e51b9ffe295e49be0dc1884269e57 3 | timeCreated: 1500836921 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Extensions/Vector2Extensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 803665cf94df6fb44a19ea660e2865af 3 | timeCreated: 1471939238 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Extensions/Vector3Extensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b31a13fae38d4554ea59163f370ee508 3 | timeCreated: 1471749945 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/CapsuleCapsuleCollision.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e8d0b0d08b6268044b8852e64c3d6ac0 3 | timeCreated: 1471769129 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/CapsuleCapsuleResolution.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1c9cbb891f16e604da898df9c3befb27 3 | timeCreated: 1496967269 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/ClosestOnTwoLineSegments.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 358b73432603cd642bfdabc1ec401c9c 3 | timeCreated: 1486105540 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/ColliderPhysicsResearch.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ecceddaa7f0c0a4e9a572e89f103de3 3 | timeCreated: 1502044809 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/LineSegmentConeCollision.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c8fe5428cc1484e409230ea5713ce407 3 | timeCreated: 1489011821 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/LineSegmentDiskCollision.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 838326f73f773fd438e4f07444fc31ff 3 | timeCreated: 1476218749 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/TriangleSphereCollision.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 97661ce89bcfad646a3e6cd8ea6ebb77 3 | timeCreated: 1471755471 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/TriangleTriangleCollision.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f777637e7fc4956478885c884345485d 3 | timeCreated: 1471755162 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/TwoJoinsInverseKinematics.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e9d52b32e38018048bfb3854407ffe0d 3 | timeCreated: 1500782938 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/v3.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 88cdeca37da710f46a7166152fdd903d 3 | timeCreated: 1528054731 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/AxisAlignedBoundingBoxCollision.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e8a4b04dbd3e9bc4497ae09af27fb1eb 3 | timeCreated: 1471769129 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/MiscTests/Test2D3DConversion.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 26a677885399a7f4093a0699dde6c353 3 | timeCreated: 1473658559 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/MiscTests/TestComputeRelative.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d741e0c574cacb2448f2e974388c0be4 3 | timeCreated: 1473423476 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/RelativeRotationDistribution.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bf24658cfc4021648a758519751d4757 3 | timeCreated: 1500833301 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/MiscTests/TestMoreThan360Rotation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4c794db9e3741e47a363349f10f42a7 3 | timeCreated: 1474552231 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/MiscTests/TestRotationByTwoVectorsAndAxis.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f71a9ea1b3ad0049b37e11f16ccb5c7 3 | timeCreated: 1474615168 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Extensions/IntExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e662b58b45380a418e016f5cf3d0a13 3 | timeCreated: 1528055035 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Extensions/DoubleExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 386d95aec4f30fb46bc3a032dbfbe4ca 3 | timeCreated: 1528054486 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/FingerInverseKinematics.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1b1bbe1ddafc0354396ae1242fd196ff 3 | timeCreated: 1527674910 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/ThreeJoinsInverseKinematics.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c758ff0967699d4429e24cf6c6fc2535 3 | timeCreated: 1527669473 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /UnityFunctions/UnityFunctions.sln.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | DO_NOT_SHOW 3 | DO_NOT_SHOW 4 | True -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | [Bb]uilds/ 6 | Assets/AssetStoreTools* 7 | 8 | .DS_Store 9 | .vs 10 | 11 | # Autogenerated VS/MD solution and project files 12 | ExportedObj/ 13 | *.csproj 14 | *.unityproj 15 | *.suo 16 | *.tmp 17 | *.user 18 | *.userprefs 19 | *.pidb 20 | *.booproj 21 | *.svd 22 | *.blend1 23 | *.blend2 24 | *.blend1.meta 25 | *.blend2.meta 26 | _ReSharper.* 27 | 28 | # Unity3D generated meta files 29 | *.pidb.meta 30 | 31 | # Unity3D Generated File On Crash Reports 32 | sysinfo.txt 33 | 34 | # Builds 35 | *.apk 36 | *.unitypackage 37 | 38 | UnityFunctions/UnityFunctions.exe 39 | UnityFunctions/player_win_x86.pdb 40 | UnityFunctions/player_win_x86_s.pdb 41 | UnityFunctions/player_win_x64.pdb 42 | UnityFunctions/player_win_x64_s.pdb 43 | UnityFunctions/UnityFunctions.apk 44 | UnityFunctions/UnityFunctions_Data/* 45 | 46 | -------------------------------------------------------------------------------- /UnityFunctions/UnityFunctions.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp", "Assembly-CSharp.csproj", "{EEF5831B-C901-5DD4-0813-440D69CB5DE3}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {EEF5831B-C901-5DD4-0813-440D69CB5DE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {EEF5831B-C901-5DD4-0813-440D69CB5DE3}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {EEF5831B-C901-5DD4-0813-440D69CB5DE3}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {EEF5831B-C901-5DD4-0813-440D69CB5DE3}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Extensions/GameObjectExtensions.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Extensions 4 | { 5 | internal static class GameObjectExtensions 6 | { 7 | internal static GameObject SetStandardShaderTransparentColor(this GameObject go, Color color) 8 | { 9 | return go.SetStandardShaderTransparentColor(color.r,color.g,color.b,color.a); 10 | } 11 | internal static GameObject SetStandardShaderTransparentColor(this GameObject go, double r, double g, double b, double a) 12 | { 13 | var renderer = go.GetComponent(); 14 | if (renderer != null) 15 | { 16 | renderer.material.SetStandardShaderRenderingModeTransparent(); 17 | renderer.material.color = new Color((float)r,(float)g,(float)b,(float)a); 18 | } 19 | return go; 20 | } 21 | internal static GameObject SetName(this GameObject go, string name) 22 | { 23 | go.name = name; 24 | return go; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/v2.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Assets.Scripts 4 | { 5 | internal static class v2 6 | { 7 | /// 8 | /// 0, 0 9 | /// 10 | internal static Vector2 zero = new Vector2(0, 0); 11 | /// 12 | /// 1, 1 13 | /// 14 | internal static Vector2 one = new Vector2(1, 1); 15 | /// 16 | /// 1, 0 17 | /// 18 | internal static Vector2 unitX = new Vector2(1, 0); 19 | /// 20 | /// 0, 1 21 | /// 22 | internal static Vector2 unitY = new Vector2(0, 1); 23 | /// 24 | /// 0, 1 25 | /// 26 | internal static Vector2 up = new Vector2(0, 1); 27 | /// 28 | /// 0, -1 29 | /// 30 | internal static Vector2 down = new Vector2(0, -1); 31 | /// 32 | /// 1, 0 33 | /// 34 | internal static Vector2 right = new Vector2(1, 0); 35 | /// 36 | /// -1, 0 37 | /// 38 | internal static Vector2 left = new Vector2(-1, 0); 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/SpringFunctionality.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Services; 3 | using Unianio; 4 | using UnityEngine; 5 | using UnityEngine.UI; 6 | using UnityFunctions; 7 | 8 | namespace Main 9 | { 10 | public class SpringFunctionality : BaseMainScript 11 | { 12 | IPendulumPhysicsAgent _ppa; 13 | Transform _soft, _rigid; 14 | Text _log; 15 | 16 | void Start() 17 | { 18 | // fun.setTimeScale(0.2); 19 | 20 | _soft = GameObject.CreatePrimitive(PrimitiveType.Sphere).transform 21 | .SetScale(1.2).SetColor(0xFF0000FF).SetHideFlags(HideFlags.HideInHierarchy); 22 | 23 | _rigid = GameObject.CreatePrimitive(PrimitiveType.Cube).transform 24 | .SetScale(1).SetColor(0x0000FFFF).SetPosition(-2.5, 0, 0); 25 | 26 | _ppa = new PendulumPhysicsAgent(); 27 | 28 | _log = GameObject.Find("LogText").GetComponent(); 29 | } 30 | void Update() 31 | { 32 | fun.frame(); 33 | var p = V3(5, 0, 0).AsWorldPoint(_rigid); 34 | Debug.DrawLine(p, _rigid.position, Color.yellow, 0, false); 35 | _soft.position = _ppa.Compute(p); 36 | 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Extensions/TransformExtensions.cs: -------------------------------------------------------------------------------- 1 | using Unianio; 2 | using UnityEngine; 3 | 4 | namespace Extensions 5 | { 6 | public static class TransformExtensions 7 | { 8 | public static Transform SetPosition(this Transform transform, in Vector3 pos) 9 | { 10 | transform.position = pos; 11 | return transform; 12 | } 13 | public static Transform SetPosition(this Transform transform, double x, double y, double z) 14 | { 15 | transform.position = new Vector3((float)x, (float)y, (float)z); 16 | return transform; 17 | } 18 | public static Transform SetScale(this Transform transform, double scale) 19 | { 20 | transform.localScale = new Vector3((float)scale, (float)scale, (float)scale); 21 | return transform; 22 | } 23 | public static Transform SetHideFlags(this Transform transform, HideFlags flags) 24 | { 25 | transform.hideFlags = flags; 26 | return transform; 27 | } 28 | public static Transform SetColor(this Transform transform, uint color) 29 | { 30 | transform.GetComponentInChildren().material.color = fun.color.Parse(color); 31 | return transform; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Draw2D.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ``` 4 | var t1in2d = t1.As2d(ref x2d, ref y2d) + Vector2.right; 5 | var t2in2d = t2.As2d(ref x2d, ref y2d) + Vector2.right; 6 | var t3in2d = t3.As2d(ref x2d, ref y2d) + Vector2.right; 7 | var spin2d = spherePos.As2d(ref x2d, ref y2d) + Vector2.right; 8 | var radius2d = (float) Math.Sqrt(1.0 - ratio*ratio)*_sphereRadius; 9 | 10 | var hasCollision = HasCircleTriangleCollision2D(ref spin2d, radius2d, ref t1in2d, ref t2in2d, ref t3in2d); 11 | 12 | 13 | float i, j; 14 | for (i = -1f, j = -1+0.05f; j <= 1f; i += 0.05f, j += 0.05f) 15 | { 16 | var x1 = i; 17 | var y1 = (float)Mathf.Sqrt(1f - x1*x1); 18 | 19 | var x2 = j; 20 | var y2 = (float)Mathf.Sqrt(1f - x2*x2); 21 | Debug.DrawLine(new Vector3(spin2d.x+x1*radius2d, spin2d.y+y1*radius2d), new Vector3(spin2d.x+x2*radius2d, spin2d.y+y2*radius2d), hasCollision ? Color.yellow : Color.gray, 0, false); 22 | Debug.DrawLine(new Vector3(spin2d.x+x1*radius2d, spin2d.y-y1*radius2d), new Vector3(spin2d.x+x2*radius2d, spin2d.y-y2*radius2d), hasCollision ? Color.yellow : Color.gray, 0, false); 23 | } 24 | 25 | Debug.DrawLine(t1in2d, t2in2d, hasCollision ? Color.cyan : Color.gray, 0, false); 26 | Debug.DrawLine(t2in2d, t3in2d, hasCollision ? Color.cyan : Color.gray, 0, false); 27 | Debug.DrawLine(t3in2d, t1in2d, hasCollision ? Color.cyan : Color.gray, 0, false); 28 | 29 | ``` 30 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/dbg.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using UnityEngine; 4 | 5 | namespace UnityFunctions 6 | { 7 | internal static class dbg 8 | { 9 | public static object Info = ""; 10 | 11 | private static bool _appendInitialized; 12 | internal static readonly string logFilePath = Application.persistentDataPath + @"/__log.txt"; 13 | internal static void log(params object[] args) 14 | { 15 | if (!_appendInitialized) 16 | { 17 | clear(); 18 | } 19 | System.IO.File.AppendAllText(logFilePath, string.Join("\t", args.Select(Convert.ToString).ToArray()) + "\r\n"); 20 | } 21 | internal static void clear() 22 | { 23 | System.IO.File.WriteAllText(logFilePath, ""); 24 | _appendInitialized = true; 25 | } 26 | internal static int int1; 27 | internal static Vector3 v1; 28 | internal static Vector3 v2; 29 | internal static Vector3 v3; 30 | internal static string st 31 | { 32 | get 33 | { 34 | System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(); 35 | return trace.ToString(); //StackTraceUtility.ExtractStackTrace(); 36 | } 37 | } 38 | 39 | } 40 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/MiscTests/TestMoreThan360Rotation.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Main.MiscTests 7 | { 8 | public class TestMoreThan360Rotation : BaseMainScript 9 | { 10 | private Transform _capsule; 11 | 12 | private readonly TimeRange _time = new TimeRange(); 13 | private AngleAxisData _rotation; 14 | 15 | void Start () 16 | { 17 | _capsule = 18 | fun.meshes.CreateCapsule( 19 | new DtCapsule 20 | { 21 | name = "capsule", 22 | radius = 0.1, 23 | height = 1 24 | }) 25 | .SetStandardShaderTransparentColor(0,1,0,0.6) 26 | .transform; 27 | _capsule.LookAt(Vector3.one*10); 28 | 29 | _time.SetTime(3); 30 | _rotation = new AngleAxisData (720, Vector3.up); 31 | 32 | } 33 | 34 | void Update() 35 | { 36 | var x = _time.Progress().Clamp01(); 37 | var ini = Vector3.one.normalized; 38 | 39 | // test code STARTS here ----------------------------------------------- 40 | ini = _rotation.Slerp(x)*ini; 41 | _capsule.LookAt(ini*100); 42 | // test code ENDS here ------------------------------------------------- 43 | 44 | 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/AxisAlignedBoundingBoxCollision.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Main 7 | { 8 | public class AxisAlignedBoundingBoxCollision : BaseMainScript 9 | { 10 | private Transform _box1, _box2; 11 | 12 | void Start () 13 | { 14 | 15 | 16 | _box1 = 17 | fun.meshes.CreateBox(new DtBox {side = 1, name = "box_1"}) 18 | .transform; 19 | _box2 = 20 | fun.meshes.CreateBox(new DtBox { side = 1, name = "box_2" }) 21 | .transform; 22 | _box2.position += Vector3.forward*0.5f; 23 | 24 | } 25 | void Update() 26 | { 27 | 28 | var pos1 = _box1.position; 29 | var size1 = _box1.localScale; 30 | var pos2 = _box2.position; 31 | var size2 = _box2.localScale; 32 | 33 | 34 | 35 | // test code STARTS here ----------------------------------------------- 36 | var hasCollision = fun.intersection.BetweenAxisAlignedBoxes(in pos1, in size1, in pos2, in size2); 37 | // test code ENDS here ------------------------------------------------- 38 | 39 | 40 | SetColorOnChanged(hasCollision, rgba(0, 1, 0, 0.5), rgba(0.5,0.5,0.5,0.5), _box1); 41 | SetColorOnChanged(hasCollision, rgba(0, 1, 0, 0.5), rgba(0.5,0.5,0.5,0.5), _box2); 42 | } 43 | 44 | 45 | 46 | 47 | 48 | 49 | } 50 | } -------------------------------------------------------------------------------- /UnityFunctionsTests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("UnityFunctionsTests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("UnityFunctionsTests")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("858f631c-52c1-43c1-a8a7-85213d7af48a")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/AngleAxisData.cs: -------------------------------------------------------------------------------- 1 | using Unianio; 2 | using UnityEngine; 3 | 4 | namespace UnityFunctions 5 | { 6 | internal struct AngleAxisData 7 | { 8 | internal AngleAxisData(double angle, Vector3 axis) 9 | { 10 | Angle = (float)angle; 11 | Axis = axis; 12 | } 13 | /// 14 | /// if axis vector does not lie on the plane between the 2 vectors it will be projected there 15 | /// 16 | internal AngleAxisData(Vector3 fromVector, Vector3 toVector, Vector3 axis) 17 | { 18 | fromVector.Normalize(); 19 | toVector.Normalize(); 20 | axis.Normalize(); 21 | var planeNormal = (fromVector - toVector).normalized; 22 | fun.vector.ProjectOnPlane(in axis, in planeNormal, out axis); 23 | var q1 = Quaternion.LookRotation(fromVector, axis); 24 | var q2 = Quaternion.LookRotation(toVector, axis); 25 | var sign = fun.angle.BetweenPointsSignedInDegrees(in fromVector, in toVector, in axis) < 0 ? -1 : 1; 26 | Angle = fun.angle.Between(in q1, in q2)*sign; 27 | Axis = axis; 28 | } 29 | internal float Angle; 30 | internal Vector3 Axis; 31 | internal Quaternion Slerp(Quaternion start, double progress) 32 | { 33 | return start*Quaternion.AngleAxis(Angle*(float) progress, Axis); 34 | } 35 | internal Quaternion Slerp(double progress) 36 | { 37 | return Quaternion.AngleAxis(Angle*(float) progress, Axis); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/HueSaturationLuminance.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | namespace Main 7 | { 8 | public class HueSaturationLuminance : BaseMainScript 9 | { 10 | Material _sphere; 11 | Text _hueVal, _satVal, _lumVal; 12 | Slider _hueSld, _satSld, _lumSld; 13 | float _hue, _sat, _lum; 14 | 15 | void Start () 16 | { 17 | _sphere = fun.meshes.CreateSphere(new DtSphere {radius = 2, name = "hsl"}).GetComponent().material; 18 | _hueVal = GameObject.Find("HueValue").GetComponent(); 19 | _satVal = GameObject.Find("SatValue").GetComponent(); 20 | _lumVal = GameObject.Find("LumValue").GetComponent(); 21 | _hueSld = GameObject.Find("HueSlider").GetComponent(); 22 | _satSld = GameObject.Find("SatSlider").GetComponent(); 23 | _lumSld = GameObject.Find("LumSlider").GetComponent(); 24 | _hueSld.value = _hue = 0.0f; 25 | _satSld.value = _sat = 1.0f; 26 | _lumSld.value = _lum = 0.5f; 27 | 28 | } 29 | 30 | void Update() 31 | { 32 | _hue = _hueSld.value; 33 | _sat = _satSld.value; 34 | _lum = _lumSld.value; 35 | _hueVal.text = _hue.ToString("F2"); 36 | _satVal.text = _sat.ToString("F2"); 37 | _lumVal.text = _lum.ToString("F2"); 38 | _sphere.color = fun.color.FromHueSaturationLuminance(_hue.Round(2), _sat.Round(2), _lum.Round(2)); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/MiscTests/TestRotationByTwoVectorsAndAxis.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using UnityEngine; 3 | using UnityFunctions; 4 | 5 | namespace Main.MiscTests 6 | { 7 | public class TestRotationByTwoVectorsAndAxis : BaseMainScript 8 | { 9 | private const float seconds = 2.5f; 10 | private readonly Vector3 _from = new Vector3(1,0,0); 11 | private readonly Vector3 _to = new Vector3(0,1,0); 12 | private readonly Vector3 _axis = new Vector3(1,1,0).normalized; 13 | private readonly TimeRange _time = new TimeRange(); 14 | private AngleAxisData _rotation; 15 | 16 | void Start () 17 | { 18 | 19 | 20 | _time.SetTime(seconds); 21 | _rotation = new AngleAxisData (_from, _to, _axis); 22 | Debug.Log(_rotation.Angle); 23 | } 24 | 25 | void FixedUpdate() 26 | { 27 | var x = _time.Progress() % 1; 28 | dbg.log(x); 29 | var ini = _from; 30 | 31 | // test code STARTS here ----------------------------------------------- 32 | var curr = _rotation.Slerp(x)*ini; 33 | 34 | // test code ENDS here ------------------------------------------------- 35 | 36 | Debug.DrawLine(Vector3.zero, curr, Color.green, seconds/2f); 37 | 38 | Debug.DrawLine(Vector3.zero, _axis, Color.black, 0); 39 | Debug.DrawLine(Vector3.zero, _rotation.Axis, Color.white, 0); 40 | Debug.DrawLine(Vector3.zero, _from, Color.red, 0); 41 | Debug.DrawLine(Vector3.zero, _to, Color.blue, 0); 42 | 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /UnityFunctionsTests/IntersectionTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NUnit.Framework; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace UnityFunctionsTests 7 | { 8 | [TestFixture] 9 | public class IntersectionTests 10 | { 11 | [Test] 12 | public void Can_find_intersection_Between_2D_Triangle_And_Line_Segment() 13 | { 14 | var t1in2d = new Vector2(0,0); 15 | var t2in2d = new Vector2(0.241f,0.06999999f); 16 | var t3in2d = new Vector2(-0.713f,0.859f); 17 | var w1in2d = new Vector2(-0.013f,0.359f); 18 | var w2in2d = new Vector2(-0.413f,0.359f); 19 | //Console.WriteLine(t1in2d.x+","+t1in2d.y+" "+t2in2d.x+","+t2in2d.y+" "+t3in2d.x+","+t3in2d.y+" "+w1in2d.x+","+w1in2d.y+" "+w2in2d.x+","+w2in2d.y+" "); 20 | 21 | Vector2 int2d; 22 | var r = 23 | fun.intersection.Between2DTriangleAndLineSegment( 24 | ref t1in2d, ref t2in2d, ref t3in2d, 25 | ref w1in2d, ref w2in2d, out int2d); 26 | 27 | Assert.That(r,Is.True); 28 | } 29 | 30 | [Test] 31 | public void Can_find_intersection_Between_2D_Lines() 32 | { 33 | var t2 = new Vector2(0.241f,0.06999999f); 34 | var t3 = new Vector2(-0.713f,0.859f); 35 | var line1 = new Vector2(-0.013f,0.359f); 36 | var line2 = new Vector2(-0.413f,0.359f); 37 | Vector2 curr; 38 | var r = 39 | fun.intersection.Between2DLines(ref t2, ref t3, ref line1, ref line2, out curr); 40 | Assert.That(r,Is.True); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/ProjectPointOnPlane.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Main; 3 | using Unianio; 4 | using UnityEngine; 5 | using UnityFunctions; 6 | 7 | namespace Main 8 | { 9 | public class ProjectPointOnPlane : BaseMainScript 10 | { 11 | private Transform _point, _projection; 12 | 13 | // Drag the white ball in Scene view 14 | void Start () 15 | { 16 | const float pointSize = 0.025f; 17 | CreateTriangle(pointSize); 18 | 19 | _point = 20 | fun.meshes.CreateSphere(new DtSphere {radius = pointSize}) 21 | .SetStandardShaderTransparentColor(1,1,1,0.9).transform; 22 | _projection = 23 | fun.meshes.CreateSphere(new DtSphere {radius = pointSize}) 24 | .SetStandardShaderTransparentColor(1,0,0,0.9).transform; 25 | 26 | _point.position += Vector3.forward*0.5f; 27 | } 28 | 29 | // Update is called once per frame 30 | void Update () 31 | { 32 | Vector3 a, b, c, planeNormal; 33 | SetTriangle(out a, out b, out c, out planeNormal); 34 | 35 | var p = _point.position; 36 | 37 | // test code STARTS here ----------------------------------------------- 38 | _projection.position = fun.point.ProjectOnPlane(p, planeNormal, a); 39 | var isAbove = fun.point.IsAbovePlane(p, planeNormal, a); 40 | // test code ENDS here ------------------------------------------------- 41 | 42 | SetColorOnChanged(isAbove,new Color(0,1,0,0.9f),new Color(1,0,0,0.9f),_projection); 43 | Debug.DrawLine(p,_projection.position, isAbove ? Color.red : Color.black, 0, true); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /UnityFunctions/packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.ads": "2.3.1", 4 | "com.unity.analytics": "3.2.2", 5 | "com.unity.collab-proxy": "1.2.15", 6 | "com.unity.package-manager-ui": "2.0.3", 7 | "com.unity.purchasing": "2.0.3", 8 | "com.unity.textmeshpro": "1.3.0", 9 | "com.unity.modules.ai": "1.0.0", 10 | "com.unity.modules.animation": "1.0.0", 11 | "com.unity.modules.assetbundle": "1.0.0", 12 | "com.unity.modules.audio": "1.0.0", 13 | "com.unity.modules.cloth": "1.0.0", 14 | "com.unity.modules.director": "1.0.0", 15 | "com.unity.modules.imageconversion": "1.0.0", 16 | "com.unity.modules.imgui": "1.0.0", 17 | "com.unity.modules.jsonserialize": "1.0.0", 18 | "com.unity.modules.particlesystem": "1.0.0", 19 | "com.unity.modules.physics": "1.0.0", 20 | "com.unity.modules.physics2d": "1.0.0", 21 | "com.unity.modules.screencapture": "1.0.0", 22 | "com.unity.modules.terrain": "1.0.0", 23 | "com.unity.modules.terrainphysics": "1.0.0", 24 | "com.unity.modules.tilemap": "1.0.0", 25 | "com.unity.modules.ui": "1.0.0", 26 | "com.unity.modules.uielements": "1.0.0", 27 | "com.unity.modules.umbra": "1.0.0", 28 | "com.unity.modules.unityanalytics": "1.0.0", 29 | "com.unity.modules.unitywebrequest": "1.0.0", 30 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 31 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 32 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 33 | "com.unity.modules.unitywebrequestwww": "1.0.0", 34 | "com.unity.modules.vehicles": "1.0.0", 35 | "com.unity.modules.video": "1.0.0", 36 | "com.unity.modules.vr": "1.0.0", 37 | "com.unity.modules.wind": "1.0.0", 38 | "com.unity.modules.xr": "1.0.0" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/TriangleLineCollision.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Main; 3 | using Unianio; 4 | using UnityEngine; 5 | using UnityFunctions; 6 | 7 | namespace Main 8 | { 9 | public class TriangleLineCollision : BaseMainScript 10 | { 11 | private Transform _t, _line1, _line2; 12 | 13 | 14 | void Start () 15 | { 16 | const float pointSize = 0.025f; 17 | _t = CreateTriangle(pointSize).transform; 18 | 19 | _line1 = fun.meshes.CreateSphere(new DtSphere {radius = pointSize}).SetStandardShaderTransparentColor(0,1,0,0.9).transform; 20 | _line2 = fun.meshes.CreateSphere(new DtSphere {radius = pointSize}).SetStandardShaderTransparentColor(0,1,0,0.9).transform; 21 | 22 | _line1.position += Vector3.forward*-0.3f; 23 | _line2.position += Vector3.forward*0.3f; 24 | } 25 | 26 | void Update() 27 | { 28 | Vector3 tp1,tp2,tp3; 29 | SetTriangle(out tp1 , out tp2, out tp3); 30 | var line1 = _line1.position; 31 | var line2 = _line2.position; 32 | 33 | // test code STARTS here ----------------------------------------------- 34 | var hasIntersection = 35 | fun.intersection.BetweenTriangleAndLineSegment(in tp1, in tp2, in tp3, in line1, in line2); 36 | // test code ENDS here ------------------------------------------------- 37 | 38 | Debug.DrawLine(line1, line2, hasIntersection ? Color.green : Color.red, 0, true); 39 | 40 | SetColorOnChanged(hasIntersection, Color.green, Color.grey, _a, _b, _c, _line1, _line2); 41 | SetColorOnChanged(hasIntersection, new Color(0,0,1,0.5f), new Color(0.7f,0.8f,1f,0.5f), _t.transform); 42 | } 43 | 44 | 45 | } 46 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/TriangleSphereCollision.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Main 7 | { 8 | public class TriangleSphereCollision : BaseMainScript 9 | { 10 | private Transform _sphere; 11 | private float _sphereRadius; 12 | private Transform _collision; 13 | 14 | 15 | void Start () 16 | { 17 | const float pointSize = 0.025f; 18 | CreateTriangle(pointSize); 19 | _sphereRadius = 0.2f; 20 | 21 | _sphere = fun.meshes.CreateSphere(new DtSphere {radius = _sphereRadius,name = "sphere"}).transform; 22 | 23 | _collision = 24 | fun.meshes.CreateSphere(new DtSphere {radius = 0.03,name = "collision"}) 25 | .SetStandardShaderTransparentColor(1,0,0,0.9).transform; 26 | 27 | } 28 | 29 | void Update() 30 | { 31 | Vector3 t1, t2, t3, triangleNormal; 32 | SetTriangle(out t1, out t2, out t3, out triangleNormal); 33 | var spherePos = _sphere.position; 34 | 35 | // test code STARTS here ----------------------------------------------- 36 | 37 | Vector3 collision; 38 | var hasCollision = 39 | fun.intersection.BetweenTriangleAndSphere( 40 | in t1, in t2, in t3, 41 | in spherePos, _sphereRadius, 42 | out collision); 43 | 44 | // test code ENDS here ------------------------------------------------- 45 | 46 | _collision.position = hasCollision ? collision : new Vector3(0,999,0); 47 | SetColorOnChanged(hasCollision, rgba(0,1,0,0.8), rgba(0.5,0.5,0.5,0.8), _sphere, _a, _b, _c); 48 | } 49 | 50 | 51 | } 52 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/RaySphereCollision.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Extensions; 3 | using Main; 4 | using Unianio; 5 | using UnityEngine; 6 | using UnityFunctions; 7 | 8 | namespace Main 9 | { 10 | public class RaySphereCollision : BaseMainScript 11 | { 12 | private const float SphereRadius = 0.3f; 13 | 14 | private Transform _origin; 15 | private Transform _sphere; 16 | 17 | void Start () 18 | { 19 | const float pointSize = 0.025f; 20 | _origin = 21 | fun.meshes.CreatePointyCone(new DtCone {height = pointSize*2,bottomRadius = pointSize*2,topRadius = 0.001f}) 22 | .SetStandardShaderTransparentColor(1,0,1,0.5).transform; 23 | _origin.position += Vector3.forward*-0.5f; 24 | 25 | _sphere = fun.meshes.CreateSphere(new DtSphere {radius = SphereRadius}).transform; 26 | _sphere.position += Vector3.forward*0.5f; 27 | } 28 | 29 | void Update () 30 | { 31 | var sphereCenter = _sphere.position; 32 | var rayOr = _origin.position; 33 | var rayFw = _origin.forward; 34 | 35 | 36 | // test code STARTS here ----------------------------------------------- 37 | Vector3 collision; 38 | var hasCollision = 39 | fun.intersection.BetweenRayAndSphere( 40 | in rayFw, in rayOr, in sphereCenter, SphereRadius, out collision); 41 | // test code ENDS here ------------------------------------------------- 42 | if (hasCollision) 43 | { 44 | Debug.DrawLine(rayOr, collision, Color.red, 0, false); 45 | } 46 | 47 | SetColorOnChanged(hasCollision,rgba(0,1,0,0.5),rgba(0.5,0.5,0.5,0.5), _sphere); 48 | 49 | } 50 | 51 | 52 | } 53 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/TriangleDiskCollision.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Main 7 | { 8 | public class TriangleDiskCollision : BaseMainScript 9 | { 10 | private Transform _disk; 11 | private Transform _collision; 12 | private const float DiskRadius = 0.2f; 13 | 14 | 15 | void Start () 16 | { 17 | CreateTriangle(0.025f); 18 | 19 | _disk = 20 | fun.meshes.CreateCone( 21 | new DtCone 22 | { 23 | name = "Disk", 24 | bottomRadius = DiskRadius, 25 | height = 0.001f, 26 | topRadius = 0.001f 27 | }) 28 | .transform; 29 | 30 | _collision = 31 | fun.meshes.CreateSphere(new DtSphere {radius = 0.03, name = "collision"}) 32 | .SetStandardShaderTransparentColor(1,0,0,0.9).transform; 33 | } 34 | void Update() 35 | { 36 | Vector3 t1, t2, t3, triangleNormal; 37 | SetTriangle(out t1, out t2, out t3, out triangleNormal); 38 | 39 | var diskNormal = _disk.up; 40 | var diskCenter = _disk.position; 41 | 42 | // test code STARTS here ----------------------------------------------- 43 | Vector3 collision; 44 | var hasCollision = 45 | fun.intersection.BetweenTriangleAndDisk( 46 | in t1, in t2, in t3, 47 | in diskNormal, in diskCenter, DiskRadius, 48 | out collision); 49 | // test code ENDS here ------------------------------------------------- 50 | 51 | _collision.position = hasCollision ? collision : new Vector3(0,999,0); 52 | SetColorOnChanged(hasCollision, rgba(0,1,0,0.7), rgba(0.5,0.5,0.5,0.7), _disk, _a, _b, _c); 53 | } 54 | 55 | } 56 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/SoftBodyJiggle.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Services; 3 | using Unianio; 4 | using UnityEngine; 5 | using UnityEngine.UI; 6 | using UnityFunctions; 7 | 8 | namespace Main 9 | { 10 | public class SoftBodyJiggle : BaseMainScript 11 | { 12 | ISoftBodyJiggleAgent _sja; 13 | Transform _bone, _rigid; 14 | Text _log; 15 | 16 | void Start() 17 | { 18 | // fun.setTimeScale(0.2); 19 | 20 | // Application.targetFrameRate = 90; 21 | // QualitySettings.vSyncCount = 0; 22 | 23 | 24 | var cone = fun.meshes.CreatePointyCone( 25 | new DtCone 26 | { 27 | height = 0.5, 28 | topRadius = 0.001, 29 | bottomRadius = 0.5, 30 | relNoseLen = 5 31 | }).transform 32 | .SetColor(0xFF0000FF) 33 | // .SetHideFlags(HideFlags.HideInHierarchy) 34 | ; 35 | 36 | _bone = new GameObject("Soft").transform.SetPosition(-3, 0, 0); 37 | cone.SetParent(_bone); 38 | cone.localRotation = Quaternion.LookRotation(v3.bk, v3.up); 39 | cone.localPosition = V3(0, 0, 3); 40 | _bone.rotation = Quaternion.LookRotation(v3.rt, v3.up); 41 | 42 | _rigid = GameObject.CreatePrimitive(PrimitiveType.Cube).transform 43 | .SetColor(0x0000FFFF).SetPosition(-4, 0, 0); 44 | 45 | _bone.SetParent(_rigid); 46 | 47 | _sja = new SoftBodyJiggleAgent(new SoftBodyConfig 48 | { 49 | Bone = _bone, 50 | RelTargetAt = 3, 51 | MaxDegrees = 50 52 | }); 53 | 54 | _log = GameObject.Find("LogText").GetComponent(); 55 | } 56 | void Update() 57 | { 58 | fun.frame(); 59 | 60 | var r = _sja.Compute(); 61 | 62 | _bone.position = r.position; 63 | _bone.rotation = r.rotation; 64 | 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/MiscTests/TestComputeRelative.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Main.MiscTests 7 | { 8 | public class TestComputeRelative : BaseMainScript 9 | { 10 | const float CapsuleHeight = 2f; 11 | const float CapsuleRadius = 0.5f; 12 | private Transform _capsule; 13 | 14 | void Start () 15 | { 16 | _capsule = 17 | fun.meshes.CreateCapsule( 18 | new DtCapsule 19 | { 20 | name = "capsule", 21 | radius = CapsuleRadius, 22 | height = CapsuleHeight 23 | }) 24 | .SetStandardShaderTransparentColor(0,1,0,0.6) 25 | .transform; 26 | 27 | _capsule.position += Vector3.forward*0.9f; 28 | _capsule.LookAt(Vector3.one*10); 29 | } 30 | 31 | void Update() 32 | { 33 | _capsule.RotateAround(Vector3.zero, Vector3.up, 90*Time.smoothDeltaTime); 34 | 35 | var moveUp = (CapsuleHeight/2) + CapsuleRadius; 36 | 37 | var p1Wor1 = _capsule.TransformPoint(Vector3.up*moveUp); 38 | var p2Wor1 = _capsule.TransformPoint(Vector3.up*moveUp + Vector3.forward*(CapsuleRadius*2)); 39 | 40 | 41 | // test code STARTS here ----------------------------------------------- 42 | var p1Loc = fun.point.ToLocal(p1Wor1, _capsule.rotation, _capsule.position); 43 | var p2Loc = fun.point.ToLocal(p2Wor1, _capsule.rotation, _capsule.position); 44 | 45 | var p1Wor2 = fun.point.ToWorld(p1Loc+Vector3.right*0.02f, _capsule.rotation, _capsule.position); 46 | var p2Wor2 = fun.point.ToWorld(p2Loc+Vector3.right*0.02f, _capsule.rotation, _capsule.position); 47 | 48 | // test code ENDS here ------------------------------------------------- 49 | 50 | 51 | Debug.DrawLine(p1Wor1, p2Wor1, Color.red, 0, false); 52 | Debug.DrawLine(p1Wor2, p2Wor2, Color.black, 0, false); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/RayCapsuleCollision.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Main 7 | { 8 | public class RayCapsuleCollision : BaseMainScript 9 | { 10 | private const float CapsuleRadius = 0.1f; 11 | private const float CapsuleHeight = 0.8f; 12 | private Transform _origin; 13 | private Transform _capsule; 14 | 15 | void Start () 16 | { 17 | const float pointSize = 0.025f; 18 | _origin = 19 | fun.meshes.CreatePointyCone(new DtCone {height = pointSize*2,bottomRadius = pointSize*2,topRadius = 0.001f}) 20 | .SetStandardShaderTransparentColor(1,0,1,0.5).transform; 21 | _origin.position += Vector3.forward*-0.5f; 22 | 23 | _capsule = fun.meshes.CreateCapsule(new DtCapsule {radius = CapsuleRadius, height = CapsuleHeight, name = "capsule"}).transform; 24 | _capsule.position += Vector3.forward*0.5f; 25 | } 26 | 27 | void Update () 28 | { 29 | var c1p1 = _capsule.position - _capsule.up*(CapsuleHeight/2); 30 | var c1p2 = _capsule.position + _capsule.up*(CapsuleHeight/2); 31 | var rayOr = _origin.position; 32 | var rayFw = _origin.forward; 33 | 34 | // test code STARTS here ----------------------------------------------- 35 | Vector3 collision; 36 | var hasCollision = 37 | fun.intersection.BetweenRayAndCapsule( 38 | in rayFw, in rayOr, in c1p1, in c1p2, CapsuleRadius, out collision); 39 | // test code ENDS here ------------------------------------------------- 40 | Debug.DrawLine(rayOr, rayOr+rayFw*3, Color.gray, 0, false); 41 | if (hasCollision) 42 | { 43 | Debug.DrawLine(rayOr, collision, Color.red, 0, false); 44 | } 45 | 46 | 47 | 48 | SetColorOnChanged(hasCollision,rgba(0,1,0,0.5),rgba(0.5,0.5,0.5,0.5), _capsule); 49 | 50 | } 51 | 52 | 53 | } 54 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/CapsuleSphereCollision.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Main 7 | { 8 | public class CapsuleSphereCollision : BaseMainScript 9 | { 10 | private const float CapsuleRadius = 0.15f; 11 | private const float CapsuleHeight = 0.8f; 12 | private const float SphereRadius = 0.3f; 13 | private Transform _capsule; 14 | private Transform _sphere; 15 | private Transform _collision; 16 | 17 | void Start () 18 | { 19 | _capsule = fun.meshes.CreateCapsule( 20 | new DtCapsule {radius = CapsuleRadius, height = CapsuleHeight, name = "capsule"}) 21 | .transform; 22 | _sphere = fun.meshes.CreateSphere(new DtSphere {radius = SphereRadius}).transform; 23 | _sphere.position += Vector3.forward*0.5f; 24 | _collision = 25 | fun.meshes.CreateSphere(new DtSphere {radius = 0.03,name = "collision"}) 26 | .SetStandardShaderTransparentColor(1,0,0,0.9).transform; 27 | } 28 | 29 | void Update() 30 | { 31 | 32 | var c1p1 = _capsule.position - _capsule.up*(CapsuleHeight/2); 33 | var c1p2 = _capsule.position + _capsule.up*(CapsuleHeight/2); 34 | var sp = _sphere.position; 35 | 36 | 37 | // test code STARTS here ----------------------------------------------- 38 | Vector3 collision; 39 | var hasCollision = 40 | fun.intersection.BetweenCapsuleAndSphere( 41 | in c1p1, in c1p2, CapsuleRadius, in sp, SphereRadius, out collision); 42 | // test code ENDS here ------------------------------------------------- 43 | 44 | _collision.position = hasCollision ? collision : new Vector3(0,999,0); 45 | 46 | SetColorOnChanged(hasCollision, rgba(0, 1, 0, 0.5), rgba(0.5,0.5,0.5,0.5), _capsule); 47 | SetColorOnChanged(hasCollision, rgba(0, 1, 0, 0.5), rgba(0.5,0.5,0.5,0.5), _sphere); 48 | } 49 | 50 | 51 | 52 | 53 | 54 | 55 | } 56 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/RayTriangleCollision.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Main; 3 | using Unianio; 4 | using UnityEngine; 5 | using UnityFunctions; 6 | 7 | namespace Main 8 | { 9 | public class RayTriangleCollision : BaseMainScript 10 | { 11 | private Transform _origin; 12 | private Transform _intersection; 13 | void Start () 14 | { 15 | const float pointSize = 0.025f; 16 | CreateTriangle(pointSize); 17 | 18 | _origin = 19 | fun.meshes.CreatePointyCone(new DtCone {height = pointSize*2,bottomRadius = pointSize*2,topRadius = 0.001f}) 20 | .SetStandardShaderTransparentColor(1,0,1,0.5).transform; 21 | _origin.position += Vector3.forward*-0.5f; 22 | 23 | _intersection = 24 | fun.meshes.CreateSphere(new DtSphere {radius = pointSize, name = "intersection"}) 25 | .SetStandardShaderTransparentColor(1, 0, 0, 0.9).transform; 26 | } 27 | 28 | void Update () 29 | { 30 | Vector3 a, b, c, planeNormal; 31 | SetTriangle(out a, out b, out c, out planeNormal); 32 | 33 | var rayOr = _origin.position; 34 | var rayFw = _origin.forward; 35 | 36 | // test code STARTS here ----------------------------------------------- 37 | Vector3 p; 38 | var intersectsPlane = fun.intersection.BetweenPlaneAndRay(in planeNormal, in a, in rayFw, in rayOr, out p); 39 | var isInsideTri = intersectsPlane && fun.intersection.BetweenTriangleAndRay(in a, in b, in c, in rayFw, in rayOr); 40 | // test code ENDS here ------------------------------------------------- 41 | 42 | if (intersectsPlane) 43 | { 44 | Debug.DrawLine(rayOr,p,Color.green,0,true); 45 | } 46 | else 47 | { 48 | p = new Vector3(0,999,0); 49 | Debug.DrawLine(rayOr,rayOr+rayFw*0.2f,Color.black,0,true); 50 | } 51 | 52 | SetColorOnChanged(isInsideTri,Color.red, Color.gray, _intersection,_origin); 53 | 54 | _intersection.position = p; 55 | 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/TriangleTriangleCollision.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Main; 3 | using Unianio; 4 | using UnityEngine; 5 | using UnityFunctions; 6 | 7 | namespace Main 8 | { 9 | public class TriangleTriangleCollision : BaseMainScript 10 | { 11 | private Transform _t1p1,_t1p2,_t1p3; 12 | private Transform _t2p1,_t2p2,_t2p3; 13 | private Mesh _mesh1, _mesh2; 14 | private Transform _t1, _t2; 15 | private Transform _collision; 16 | 17 | void Start () 18 | { 19 | const float pointSize = 0.025f; 20 | _t1 = CreateTriangle(pointSize, out _t1p1, out _t1p2, out _t1p3, out _mesh1).transform; 21 | _t2 = CreateTriangle(pointSize, out _t2p1, out _t2p2, out _t2p3, out _mesh2).transform; 22 | 23 | _t2p1.position += Vector3.forward*0.5f; 24 | _t2p2.position += Vector3.forward*0.5f; 25 | _t2p3.position += Vector3.forward*0.5f; 26 | 27 | _collision = 28 | fun.meshes.CreateSphere(new DtSphere {radius = 0.03,name = "collision"}) 29 | .SetStandardShaderTransparentColor(1,0,0,0.9).transform; 30 | 31 | } 32 | 33 | void Update() 34 | { 35 | Vector3 t1p1,t1p2,t1p3,planeNormal1; 36 | SetTriangle(_t1p1, _t1p2, _t1p3, _mesh1, out t1p1 , out t1p2, out t1p3, out planeNormal1); 37 | Vector3 t2p1,t2p2,t2p3,planeNormal2; 38 | SetTriangle(_t2p1, _t2p2, _t2p3, _mesh2, out t2p1 , out t2p2, out t2p3, out planeNormal2); 39 | 40 | // test code STARTS here ----------------------------------------------- 41 | Vector3 collision; 42 | var hasCollision = 43 | fun.intersection.BetweenTriangles( 44 | in t1p1, in t1p2, in t1p3, 45 | in t2p1, in t2p2, in t2p3, out collision); 46 | // test code ENDS here ------------------------------------------------- 47 | 48 | _collision.position = hasCollision ? collision : new Vector3(0,999,0); 49 | SetColorOnChanged(hasCollision, rgba(0,1,0,0.8), rgba(0.5,0.5,0.5,0.8), _t1p1, _t1p2, _t1p3, _t2p1, _t2p2, _t2p3); 50 | SetColorOnChanged(hasCollision, rgba(0,0,1,0.5), rgba(0.7,0.8,1,0.5), _t1,_t2); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/SphereSphereCollision.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Extensions; 3 | using Main; 4 | using Unianio; 5 | using UnityEngine; 6 | using UnityFunctions; 7 | 8 | namespace Main 9 | { 10 | public class SphereSphereCollision : BaseMainScript 11 | { 12 | private const float Sphere1Radius = 0.3f; 13 | private const float Sphere2Radius = 0.9f; 14 | 15 | private Transform _sphere1, _sphere2; 16 | 17 | void Start () 18 | { 19 | _sphere1 = fun.meshes.CreateSphere(new DtSphere { radius = Sphere1Radius }).transform; 20 | _sphere2 = fun.meshes.CreateSphere(new DtSphere { radius = Sphere2Radius }).transform; 21 | _sphere2.position += Vector3.forward * 0.75f; 22 | } 23 | 24 | void Update () 25 | { 26 | var sc1 = _sphere1.position; 27 | var sc2 = _sphere2.position; 28 | 29 | 30 | // test code STARTS here ----------------------------------------------- 31 | Vector3 circleCenter; 32 | float circleRadius; 33 | var hasCollision = 34 | fun.intersection.BetweenSpheres( 35 | in sc1, Sphere1Radius, in sc2, Sphere2Radius, out circleCenter, out circleRadius); 36 | // test code ENDS here ------------------------------------------------- 37 | 38 | if (hasCollision) 39 | { 40 | var axis = (sc1 - sc2).normalized; 41 | Vector3 normX, normY; 42 | fun.vector.ComputeRandomXYAxesForPlane(in axis, out normX, out normY); 43 | 44 | Vector3 prev = Vector3.zero; 45 | for (var a = 0; a < 361; a += 10) 46 | { 47 | var curr = circleCenter + normX.RotateAbout(axis, a) * circleRadius; 48 | if(a > 0) 49 | { 50 | Debug.DrawLine(curr,prev,Color.black,0,false); 51 | } 52 | prev = curr; 53 | } 54 | } 55 | 56 | SetColorOnChanged(hasCollision, rgba(0, 1, 0, 0.5), rgba(0.5, 0.5, 0.5, 0.5), _sphere1); 57 | SetColorOnChanged(hasCollision, rgba(0, 0, 1, 0.5), rgba(0.5, 0.5, 0.5, 0.5), _sphere2); 58 | 59 | } 60 | 61 | 62 | } 63 | } -------------------------------------------------------------------------------- /UnityFunctions/Logs/Packages-Update.log: -------------------------------------------------------------------------------- 1 | 2 | === Sat Nov 10 15:29:37 2018 3 | 4 | Packages were changed. 5 | Update Mode: updateDependencies 6 | 7 | The following packages were added: 8 | com.unity.analytics@3.0.9 9 | com.unity.purchasing@2.0.1 10 | com.unity.ads@2.0.8 11 | com.unity.textmeshpro@1.3.0 12 | com.unity.package-manager-ui@2.0.3 13 | com.unity.collab-proxy@1.2.11 14 | com.unity.modules.ai@1.0.0 15 | com.unity.modules.animation@1.0.0 16 | com.unity.modules.assetbundle@1.0.0 17 | com.unity.modules.audio@1.0.0 18 | com.unity.modules.cloth@1.0.0 19 | com.unity.modules.director@1.0.0 20 | com.unity.modules.imageconversion@1.0.0 21 | com.unity.modules.imgui@1.0.0 22 | com.unity.modules.jsonserialize@1.0.0 23 | com.unity.modules.particlesystem@1.0.0 24 | com.unity.modules.physics@1.0.0 25 | com.unity.modules.physics2d@1.0.0 26 | com.unity.modules.screencapture@1.0.0 27 | com.unity.modules.terrain@1.0.0 28 | com.unity.modules.terrainphysics@1.0.0 29 | com.unity.modules.tilemap@1.0.0 30 | com.unity.modules.ui@1.0.0 31 | com.unity.modules.uielements@1.0.0 32 | com.unity.modules.umbra@1.0.0 33 | com.unity.modules.unityanalytics@1.0.0 34 | com.unity.modules.unitywebrequest@1.0.0 35 | com.unity.modules.unitywebrequestassetbundle@1.0.0 36 | com.unity.modules.unitywebrequestaudio@1.0.0 37 | com.unity.modules.unitywebrequesttexture@1.0.0 38 | com.unity.modules.unitywebrequestwww@1.0.0 39 | com.unity.modules.vehicles@1.0.0 40 | com.unity.modules.video@1.0.0 41 | com.unity.modules.vr@1.0.0 42 | com.unity.modules.wind@1.0.0 43 | com.unity.modules.xr@1.0.0 44 | 45 | === Fri Nov 16 10:32:56 2018 46 | 47 | Packages were changed. 48 | Update Mode: updateDependencies 49 | 50 | The following packages were updated: 51 | com.unity.analytics from version 3.0.9 to 3.2.0 52 | 53 | === Thu Nov 22 16:47:07 2018 54 | 55 | Packages were changed. 56 | Update Mode: updateDependencies 57 | 58 | The following packages were updated: 59 | com.unity.analytics from version 3.2.0 to 3.2.2 60 | 61 | === Fri Jan 18 22:13:32 2019 62 | 63 | Packages were changed. 64 | Update Mode: updateDependencies 65 | 66 | The following packages were updated: 67 | com.unity.ads from version 2.0.8 to 2.3.1 68 | com.unity.collab-proxy from version 1.2.11 to 1.2.15 69 | com.unity.purchasing from version 2.0.1 to 2.0.3 70 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/DiskSphereCollision.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Main 7 | { 8 | public class DiskSphereCollision : BaseMainScript 9 | { 10 | private const float DiskRadius = 0.3f; 11 | private const float SphereRadius = 0.8f; 12 | private Transform _disk; 13 | private Transform _sphere; 14 | private Transform _collision; 15 | 16 | void Start () 17 | { 18 | _disk = 19 | fun.meshes.CreateCone( 20 | new DtCone 21 | { 22 | name = "Disk", 23 | bottomRadius = DiskRadius, 24 | height = 0.001f, 25 | topRadius = 0.001f 26 | }) 27 | .transform; 28 | _sphere = 29 | fun.meshes.CreateSphere( 30 | new DtSphere 31 | { 32 | name = "Sphere", 33 | radius = SphereRadius 34 | }) 35 | .transform; 36 | _sphere.position += Vector3.forward*0.9f; 37 | 38 | _collision = 39 | fun.meshes.CreateSphere(new DtSphere {radius = 0.025,name = "collision"}) 40 | .SetStandardShaderTransparentColor(1,0,0,0.9).transform; 41 | } 42 | 43 | void Update() 44 | { 45 | var diskCenter = _disk.position; 46 | var diskPlaneNormal = _disk.up; 47 | var sphereCenter = _sphere.position; 48 | // test code STARTS here ----------------------------------------------- 49 | Vector3 collision; 50 | var hasCollision = 51 | fun.intersection.BetweenDiskAndSphere( 52 | in diskPlaneNormal, in diskCenter, DiskRadius, in sphereCenter, SphereRadius, out collision); 53 | // test code ENDS here ------------------------------------------------- 54 | 55 | _collision.position = hasCollision ? collision : new Vector3(0,999,0); 56 | 57 | SetColorOnChanged(hasCollision, rgba(0, 1, 0, 0.5), rgba(0.5,0.5,0.5,0.5), _disk); 58 | SetColorOnChanged(hasCollision, rgba(0, 0, 1, 0.5), rgba(0.5,0.5,0.5,0.5), _sphere); 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/CapsuleDiskCollision.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Main 7 | { 8 | public class CapsuleDiskCollision : BaseMainScript 9 | { 10 | private const float CapsuleRadius = 0.1f; 11 | private const float CapsuleHeight = 0.8f; 12 | private const float DiskRadius = 0.8f; 13 | private Transform _capsule; 14 | private Transform _disk; 15 | private Transform _collision; 16 | 17 | void Start () 18 | { 19 | _capsule = 20 | fun.meshes.CreateCapsule( 21 | new DtCapsule {radius = CapsuleRadius, height = CapsuleHeight, name = "capsule"}) 22 | .transform; 23 | _disk = 24 | fun.meshes.CreateCone( 25 | new DtCone 26 | { 27 | name = "Disk", 28 | bottomRadius = DiskRadius, 29 | height = 0.001f, 30 | topRadius = 0.001f 31 | }) 32 | .transform; 33 | _disk.position += Vector3.forward*0.5f; 34 | 35 | _collision = 36 | fun.meshes.CreateSphere(new DtSphere {radius = 0.01,name = "collision"}) 37 | .SetStandardShaderTransparentColor(1,0,0,0.9).transform; 38 | } 39 | 40 | void Update() 41 | { 42 | var c1p1 = _capsule.position - _capsule.up*(CapsuleHeight/2); 43 | var c1p2 = _capsule.position + _capsule.up*(CapsuleHeight/2); 44 | var diskNormal = _disk.up; 45 | var diskCenter = _disk.position; 46 | 47 | 48 | // test code STARTS here ----------------------------------------------- 49 | Vector3 collision; 50 | var hasCollision = 51 | fun.intersection.BetweenCapsuleAndDisk( 52 | in c1p1, in c1p2, CapsuleRadius, in diskNormal, in diskCenter, DiskRadius, out collision); 53 | // test code ENDS here ------------------------------------------------- 54 | 55 | _collision.position = hasCollision ? collision : new Vector3(0,999,0); 56 | 57 | SetColorOnChanged(hasCollision, rgba(0, 1, 0, 0.5), rgba(0.5,0.5,0.5,0.5), _capsule); 58 | SetColorOnChanged(hasCollision, rgba(0, 0, 1, 0.5), rgba(0.5,0.5,0.5,0.5), _disk); 59 | } 60 | 61 | } 62 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/DiskDiskCollision.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Main 7 | { 8 | public class DiskDiskCollision : BaseMainScript 9 | { 10 | private const float Disk1Radius = 0.3f; 11 | private const float Disk2Radius = 0.8f; 12 | private Transform _disk1; 13 | private Transform _disk2; 14 | private Transform _collision; 15 | 16 | void Start () 17 | { 18 | _disk1 = 19 | fun.meshes.CreateCone( 20 | new DtCone 21 | { 22 | name = "Disk1", 23 | bottomRadius = Disk1Radius, 24 | height = 0.001f, 25 | topRadius = 0.001f 26 | }) 27 | .transform; 28 | _disk2 = 29 | fun.meshes.CreateCone( 30 | new DtCone 31 | { 32 | name = "Disk2", 33 | bottomRadius = Disk2Radius, 34 | height = 0.001f, 35 | topRadius = 0.001f 36 | }) 37 | .transform; 38 | _disk2.position += Vector3.forward*0.9f; 39 | 40 | _collision = 41 | fun.meshes.CreateSphere(new DtSphere {radius = 0.025,name = "collision"}) 42 | .SetStandardShaderTransparentColor(1,0,0,0.9).transform; 43 | } 44 | 45 | void Update() 46 | { 47 | var disk1Center = _disk1.position; 48 | var disk1Up = _disk1.up; 49 | var disk2Center = _disk2.position; 50 | var disk2Up = _disk2.up; 51 | // test code STARTS here ----------------------------------------------- 52 | Vector3 collision; 53 | var hasCollision = 54 | fun.intersection.BetweenDiskAndDisk( 55 | in disk1Up, in disk1Center, Disk1Radius, in disk2Up, in disk2Center, Disk2Radius, out collision); 56 | // test code ENDS here ------------------------------------------------- 57 | 58 | _collision.position = hasCollision ? collision : new Vector3(0,999,0); 59 | 60 | SetColorOnChanged(hasCollision, rgba(0, 1, 0, 0.5), rgba(0.5,0.5,0.5,0.5), _disk1); 61 | SetColorOnChanged(hasCollision, rgba(0, 0, 1, 0.5), rgba(0.5,0.5,0.5,0.5), _disk2); 62 | } 63 | 64 | 65 | } 66 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/LineSegmentDiskCollision.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Main 7 | { 8 | public class LineSegmentDiskCollision : BaseMainScript 9 | { 10 | private Transform _disk; 11 | private Transform _collision; 12 | private Transform _lineEnd1; 13 | private Transform _lineEnd2; 14 | private const float DiskRadius = 0.2f; 15 | 16 | 17 | void Start () 18 | { 19 | _disk = 20 | fun.meshes.CreateCone( 21 | new DtCone 22 | { 23 | name = "Disk", 24 | bottomRadius = DiskRadius, 25 | height = 0.001f, 26 | topRadius = 0.001f 27 | }) 28 | .transform; 29 | 30 | _collision = 31 | fun.meshes.CreateSphere(new DtSphere {radius = 0.01, name = "collision"}) 32 | .SetStandardShaderTransparentColor(1,0,0,0.9).transform; 33 | 34 | _lineEnd1 = 35 | fun.meshes.CreateSphere(new DtSphere {radius = 0.03, name = "line1"}) 36 | .SetStandardShaderTransparentColor(0,1,0,0.9).transform; 37 | _lineEnd1.position += Vector3.forward*-0.5f; 38 | _lineEnd2 = 39 | fun.meshes.CreateSphere(new DtSphere {radius = 0.03, name = "line2"}) 40 | .SetStandardShaderTransparentColor(0,0,1,0.9).transform; 41 | _lineEnd2.position += Vector3.forward*0.5f; 42 | } 43 | void Update() 44 | { 45 | var diskNormal = _disk.up; 46 | var diskCenter = _disk.position; 47 | 48 | var l1 = _lineEnd1.position; 49 | var l2 = _lineEnd2.position; 50 | 51 | // test code STARTS here ----------------------------------------------- 52 | Vector3 collision; 53 | var hasCollision = 54 | fun.intersection.BetweenLineSegmentAndDisk( 55 | in l1, in l2, 56 | in diskNormal, in diskCenter, DiskRadius, 57 | out collision); 58 | // test code ENDS here ------------------------------------------------- 59 | 60 | Debug.DrawLine(l1,l2,hasCollision?Color.green:Color.red,0,false); 61 | _collision.position = hasCollision ? collision : new Vector3(0,999,0); 62 | SetColorOnChanged(hasCollision, rgba(0,1,0,0.7), rgba(0.5,0.5,0.5,0.7), _disk); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/ProjectVectorOnPlane.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Main; 3 | using Unianio; 4 | using UnityEngine; 5 | using UnityFunctions; 6 | 7 | namespace Main 8 | { 9 | public class ProjectVectorOnPlane : BaseMainScript { 10 | private Transform _point, _projection; 11 | 12 | void Start () 13 | { 14 | const float pointSize = 0.025f; 15 | var dt = new DtTrianglePlane(); 16 | fun.meshes.CreateTwoSidedTrianglePlane(dt).SetStandardShaderTransparentColor(0,0,1,0.5); 17 | _mesh = dt.mesh; 18 | _b = fun.meshes.CreateSphere(new DtSphere {radius = pointSize, name = "Tri_ver_b"}).SetStandardShaderTransparentColor(0,1,0,0.9).transform; 19 | _c = fun.meshes.CreateSphere(new DtSphere {radius = pointSize, name = "Tri_ver_c"}).SetStandardShaderTransparentColor(0,1,0,0.9).transform; 20 | 21 | 22 | _b.position = Vector3.forward*0.5f; 23 | _c.position = Vector3.right*0.5f; 24 | 25 | 26 | _point = 27 | fun.meshes.CreateSphere(new DtSphere {radius = pointSize}) 28 | .SetStandardShaderTransparentColor(1,1,1,0.9).transform; 29 | _projection = 30 | fun.meshes.CreateSphere(new DtSphere {radius = pointSize}) 31 | .SetStandardShaderTransparentColor(1,0,0,0.9).transform; 32 | 33 | _point.position = new Vector3(0.5f,0.5f,0.5f); 34 | } 35 | 36 | void Update () 37 | { 38 | var a = Vector3.zero; 39 | var b = _b.position; 40 | var c = _c.position; 41 | Vector3 planeNormal; 42 | fun.point.GetNormal(in c, in b, in a, out planeNormal); 43 | 44 | _mesh.vertices = new [] {b,c,a}; 45 | 46 | var vector = _point.position; 47 | 48 | // test code STARTS here ----------------------------------------------- 49 | Vector3 projection; 50 | fun.vector.ProjectOnPlane(in vector, in planeNormal, out projection); 51 | _projection.position = projection; 52 | var isAbove = fun.vector.IsAbovePlane(in vector, in planeNormal); 53 | // test code ENDS here ------------------------------------------------- 54 | // 55 | SetColorOnChanged(isAbove,new Color(0,0,1,0.9f),new Color(1,0,0,0.9f),_projection); 56 | Debug.DrawLine(Vector3.zero, projection, isAbove ? Color.blue : Color.red, 0, true); 57 | Debug.DrawLine(vector,projection, Color.black, 0, true); 58 | Debug.DrawLine(Vector3.zero,planeNormal*0.1f, Color.green, 0, true); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/DistributeCircles.cs: -------------------------------------------------------------------------------- 1 | using Assets.Scripts; 2 | using Extensions; 3 | using Unianio; 4 | using UnityEngine; 5 | using UnityEngine.UI; 6 | using UnityFunctions; 7 | 8 | namespace Main 9 | { 10 | public class DistributeCircles : BaseMainScript 11 | { 12 | const float Radius = 1; 13 | void Start () 14 | { 15 | GenerateInStages(); 16 | } 17 | void GenerateInStages() 18 | { 19 | var center = v2.zero; 20 | CreateCircle(center, Radius, Color.red); 21 | for (var a = 0.0; a <= 360; a += 60) 22 | { 23 | var pos = fun.rotate.Point2dAbout(center + (v2.unitX * (Radius * 1)), v2.zero, a); 24 | CreateCircle(pos, Radius, Color.yellow); 25 | 26 | var dir = (pos - center).normalized; 27 | 28 | CreateCircle(fun.rotate.Point2dAbout(pos + dir * Radius, pos, -30), Radius, Color.green); 29 | CreateCircle(fun.rotate.Point2dAbout(pos + dir * Radius, pos, +30), Radius, Color.green); 30 | } 31 | } 32 | 33 | void GenerateDirect() 34 | { 35 | CreateCircle(v2.zero, Radius, Color.red); 36 | for (var a = 0.0; a <= 360; a += 60) 37 | { 38 | CreateCircle(fun.rotate.Point2dAbout((v2.unitX * (Radius * 1)), v2.zero, a), Radius, Color.yellow); 39 | } 40 | for (var a = 0.0; a <= 360; a += 30) 41 | { 42 | CreateCircle(fun.rotate.Point2dAbout((v2.unitX * (Radius * 2)), v2.zero, a), Radius, Color.green); 43 | } 44 | for (var a = 0.0; a <= 360; a += 20) 45 | { 46 | CreateCircle(fun.rotate.Point2dAbout((v2.unitX * (Radius * 3)), v2.zero, a), Radius, Color.magenta); 47 | } 48 | for (var a = 0.0; a <= 360; a += 15) 49 | { 50 | CreateCircle(fun.rotate.Point2dAbout((v2.unitX * (Radius * 4)), v2.zero, a), Radius, Color.white); 51 | } 52 | } 53 | 54 | 55 | void CreateCircle(Vector2 center, double radius, Color color) 56 | { 57 | Vector3 prev = v3.zero; 58 | for(var a = 0.0; a <= 360; a += 11.25) 59 | { 60 | var curr = V3(center.x + radius, 0, center.y).RotateAbout(V3(center.x, 0, center.y), in v3.unitY, a); 61 | 62 | if(a > 0) 63 | { 64 | Debug.Log("@@"+ prev+"|"+curr); 65 | Debug.DrawLine(prev, curr, color, 99999, false); 66 | } 67 | prev = curr; 68 | } 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/AddingVectors.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Main 7 | { 8 | /// 9 | /// IMPORTANT: to manipulate cones you have to have Editor switched to Global 10 | /// 11 | public class AddingVectors : BaseMainScript 12 | { 13 | private const float arrowHeight = 0.1f; 14 | private const float arrowConeBase = 0.05f; 15 | private const float sphereRadius = 0.03f; 16 | 17 | private Transform _aFrom, _aTo, _bFrom, _bTo, _cFrom, _cTo; 18 | 19 | void Start () 20 | { 21 | var sphe = new DtSphere {radius = sphereRadius}; 22 | var cone = new DtCone {height = arrowHeight, topRadius = 0.001, bottomRadius = arrowConeBase, localPos = new Vector3(0,-arrowHeight, 0) }; 23 | 24 | _aFrom = fun.meshes.CreateSphere(sphe).SetName("A_From").SetStandardShaderTransparentColor(0, 1, 0, 1).transform; 25 | _aTo = fun.meshes.CreateCone(cone).SetName("A_To").SetStandardShaderTransparentColor(0, 1, 0, 1).transform; 26 | _bFrom = fun.meshes.CreateSphere(sphe).SetName("B_From").SetStandardShaderTransparentColor(0, 0, 1, 1).transform; 27 | _bTo = fun.meshes.CreateCone(cone).SetName("B_To").SetStandardShaderTransparentColor(0, 0, 1, 1).transform; 28 | 29 | _cFrom = fun.meshes.CreateSphere(new DtSphere {radius = sphereRadius}).SetName("C_From").SetStandardShaderTransparentColor(1, 0, 1, 1).transform; 30 | _cTo = fun.meshes.CreateCone(new DtCone {height = arrowHeight/3f, topRadius = 0.001, bottomRadius = arrowConeBase/3f, localPos = new Vector3(0,-arrowHeight/3f, 0) }).SetName("C_To").SetStandardShaderTransparentColor(1, 0, 1, 1).transform; 31 | 32 | _cFrom.position = V3(0, 0.5, 0); 33 | _aFrom.position = V3(0, 0, 0); 34 | _bFrom.position = V3(1, 0, 0); 35 | _aTo.position = V3(0.4, 0, 0); 36 | _bTo.position = V3(0.6, 0, 0); 37 | } 38 | void Update() 39 | { 40 | var vecA = _aTo.position - _aFrom.position; 41 | var vecB = _bTo.position - _bFrom.position; 42 | var cFrom = _cFrom.position; 43 | 44 | _aTo.up = vecA.normalized; 45 | _bTo.up = vecB.normalized; 46 | Debug.DrawLine(_aFrom.position, _aTo.position, new Color(0, 1, 0, 1),0,true); 47 | Debug.DrawLine(_bFrom.position, _bTo.position, new Color(0, 0, 1, 1),0,true); 48 | 49 | var vec_A_plus_B = vecA + vecB; // B relative to A 50 | var cTo = cFrom + vec_A_plus_B; 51 | Debug.DrawLine(cFrom, cTo, new Color(1, 0, 1, 1),0,true); 52 | _cTo.position = cTo; 53 | _cTo.up = vec_A_plus_B.normalized; 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Services/PendulumPhysicsAgent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Extensions; 3 | using Unianio; 4 | using UnityEngine; 5 | using static Unianio.fun; 6 | 7 | namespace Services 8 | { 9 | internal delegate bool ApplyConstrain(ref Vector3 dynamicPos, ref Vector3 velocity, in Vector3 force); 10 | internal interface IPendulumPhysicsAgent 11 | { 12 | Vector3 Compute(in Vector3 currRigidPosition, double gravity01 = 0, ApplyConstrain constrain = null); 13 | int DebugId { get; set; } 14 | } 15 | internal class PendulumPhysicsAgent : IPendulumPhysicsAgent 16 | { 17 | int _frame, _debugId; 18 | Vector3 _force, _acc, _vel, _dynamicPos; 19 | readonly float _stiffness, _mass, _damping, _gravity; 20 | // stiffness = 9, mass = 81, damping = 68, gravity = 68 21 | internal PendulumPhysicsAgent( 22 | double stiffness = 0.1f, 23 | double mass = 0.9f, 24 | double damping = 0.72f, 25 | double gravity = 0.72f) 26 | { 27 | _stiffness = (float)stiffness; 28 | _mass = (float)mass; 29 | _damping = (float)damping; 30 | _gravity = (float)gravity; 31 | } 32 | 33 | int IPendulumPhysicsAgent.DebugId 34 | { 35 | get => _debugId; 36 | set => _debugId = value; 37 | } 38 | Vector3 IPendulumPhysicsAgent.Compute(in Vector3 targetPos, double gravity01, ApplyConstrain constrain) 39 | { 40 | if (++_frame == 1) 41 | { 42 | return _dynamicPos = targetPos; 43 | } 44 | 45 | gravity01 = clamp01(gravity01); 46 | var fpsFactor = (float)(fun.smoothDeltaTime / 0.011111111); 47 | var stiffness = clamp(_stiffness, 0f, 1f); 48 | var mass = clamp(_mass, 0.00001, 1f); 49 | var damping = clamp((1 - _damping) * fpsFactor, 0f, 1f); 50 | var gravity = clamp(_gravity, 0f, 1f); 51 | //Debug.Log(stiffness+"|"+mass+"|"+damping+"|"+gravity); 52 | _force.x = (targetPos.x - _dynamicPos.x) * stiffness; 53 | _acc.x = _force.x / mass; 54 | _vel.x += _acc.x * damping; 55 | 56 | _force.y = (targetPos.y - _dynamicPos.y) * stiffness; 57 | _force.y -= ((gravity * (float)gravity01) / 10) * fpsFactor; // Add some gravity 58 | _acc.y = _force.y / mass; 59 | _vel.y += _acc.y * damping; 60 | 61 | _force.z = (targetPos.z - _dynamicPos.z) * stiffness; 62 | _acc.z = _force.z / mass; 63 | _vel.z += _acc.z * damping; 64 | 65 | constrain?.Invoke(ref _dynamicPos, ref _vel, in _force); 66 | 67 | _dynamicPos = _dynamicPos + _vel + _force; 68 | 69 | return _dynamicPos; 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/ColliderPhysicsResearch.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Main 7 | { 8 | public class ColliderPhysicsResearch : BaseMainScript 9 | { 10 | private Transform _test, _cap1, _cap2, _cap3, _sph1; 11 | const float TestSphereRadius = 0.2f; 12 | 13 | void Start () 14 | { 15 | _cap1 = CreateCapsule("cap1", 0.5, 0.10, 0, 0, 1, Vector3.zero); 16 | _cap2 = CreateCapsule("cap2", 1.0, 0.25, 0, 1, 0, Vector3.forward*0.5f); 17 | _cap3 = CreateCapsule("cap3", 0.2, 0.50, 1, 0, 0, Vector3.forward*1.5f); 18 | _sph1 = CreateSphere("sph1", 0.2, 1, 0, 1, Vector3.right); 19 | _test = fun.meshes.CreateSphere(new DtSphere {radius = TestSphereRadius, name = name}) 20 | .SetStandardShaderTransparentColor(0,0,0,0.5) 21 | .transform; 22 | _test.position = -Vector3.right; 23 | } 24 | void Update () 25 | { 26 | if(IsShiftKeyAndNumberDown(1)) RunTest(); 27 | } 28 | private void RunTest() 29 | { 30 | var colliders = Physics.OverlapSphere(_test.position, TestSphereRadius); 31 | foreach (var c in colliders) 32 | { 33 | var closest = c.ClosestToSurfacePoint(_test.position); 34 | 35 | Debug.DrawLine(closest, _test.position, Color.magenta, 5, false); 36 | Debug.Log(c.name+"|"+closest.s()+"|"+fun.distance.Between(_test.position,closest).Round(2)); 37 | } 38 | 39 | } 40 | 41 | 42 | private static Transform CreateCapsule(string name, double height, double radius, double r, double g, double b, Vector3 position) 43 | { 44 | var cap = fun.meshes.CreateCapsule(new DtCapsule {height = height, radius = radius, name = name}) 45 | .SetStandardShaderTransparentColor(r,g,b,0.5) 46 | .transform; 47 | var cc = cap.gameObject.AddComponent(); 48 | cc.height = (float)(height+radius*2); 49 | cc.radius = (float)radius; 50 | 51 | cap.position = position; 52 | return cap; 53 | } 54 | private static Transform CreateSphere(string name, double radius, double r, double g, double b, Vector3 position) 55 | { 56 | var cap = fun.meshes.CreateSphere(new DtSphere {radius = radius, name = name}) 57 | .SetStandardShaderTransparentColor(r,g,b,0.5) 58 | .transform; 59 | var cc = cap.gameObject.AddComponent(); 60 | cc.radius = (float)radius; 61 | 62 | cap.position = position; 63 | return cap; 64 | } 65 | 66 | } 67 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/CapsuleCapsuleCollision.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Main 7 | { 8 | public class CapsuleCapsuleCollision : BaseMainScript 9 | { 10 | // private const float CapsuleRadius1 = 0.12f; 11 | // private const float CapsuleRadius2 = 0.2f; 12 | // private const float CapsuleHeight1 = 0.8f; 13 | // private const float CapsuleHeight2 = 0.6f; 14 | private const float CapsuleRadius1 = 0.20f; 15 | private const float CapsuleRadius2 = 0.06f; 16 | private const float CapsuleHeight1 = 0.50f; 17 | private const float CapsuleHeight2 = 0.8f; 18 | private Transform _capsule1,_capsule2,_collision; 19 | 20 | void Start () 21 | { 22 | 23 | 24 | _capsule1 = 25 | fun.meshes.CreateCapsule( 26 | new DtCapsule {radius = CapsuleRadius1, height = CapsuleHeight1, name = "capsule_1"}) 27 | .transform; 28 | _capsule2 = 29 | fun.meshes.CreateCapsule( 30 | new DtCapsule {radius = CapsuleRadius2, height = CapsuleHeight2, name = "capsule_2"}) 31 | .transform; 32 | _capsule2.position += Vector3.forward*0.5f; 33 | _collision = 34 | fun.meshes.CreateSphere(new DtSphere {radius = 0.03,name = "collision"}) 35 | .SetStandardShaderTransparentColor(1,0,0,0.9).transform; 36 | 37 | } 38 | void Update() 39 | { 40 | var radius1 = CapsuleRadius1; 41 | var radius2 = CapsuleRadius2; 42 | var height1 = CapsuleHeight1; 43 | var height2 = CapsuleHeight2; 44 | var c1p1 = _capsule1.position - _capsule1.up*(height1/2); 45 | var c1p2 = _capsule1.position + _capsule1.up*(height1/2); 46 | var c2p1 = _capsule2.position - _capsule2.up*(height2/2); 47 | var c2p2 = _capsule2.position + _capsule2.up*(height2/2); 48 | 49 | 50 | // test code STARTS here ----------------------------------------------- 51 | Vector3 collision; 52 | var hasCollision = 53 | fun.intersection.BetweenCapsules( 54 | in c1p1, in c1p2, radius1, 55 | in c2p1, in c2p2, radius2, out collision); 56 | // test code ENDS here ------------------------------------------------- 57 | 58 | _collision.position = hasCollision ? collision : new Vector3(0,999,0); 59 | 60 | SetColorOnChanged(hasCollision, rgba(0, 1, 0, 0.5), rgba(0.5,0.5,0.5,0.5), _capsule1); 61 | SetColorOnChanged(hasCollision, rgba(0, 1, 0, 0.5), rgba(0.5,0.5,0.5,0.5), _capsule2); 62 | } 63 | 64 | 65 | 66 | 67 | 68 | 69 | } 70 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/LineSegmentConeCollision.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Main 7 | { 8 | public class LineSegmentConeCollision : BaseMainScript 9 | { 10 | private Transform _cone, _collision, _lineEnd1, _lineEnd2; 11 | private const float ConeRadius = 0.3f; 12 | private const float ConeHeight = 0.8f; 13 | 14 | void Start () 15 | { 16 | _lineEnd1 = 17 | fun.meshes.CreateSphere(new DtSphere {radius = 0.03, name = "line1"}) 18 | .SetStandardShaderTransparentColor(0,1,0,0.9).transform; 19 | _lineEnd1.position += Vector3.forward*-0.5f + Vector3.up*0.5f; 20 | _lineEnd2 = 21 | fun.meshes.CreateSphere(new DtSphere {radius = 0.03, name = "line2"}) 22 | .SetStandardShaderTransparentColor(0,0,1,0.9).transform; 23 | _lineEnd2.position += Vector3.forward*0.5f + Vector3.up*0.5f; 24 | 25 | 26 | _cone = 27 | fun.meshes.CreateCone( 28 | new DtCone 29 | { 30 | name = "Cone", 31 | bottomRadius = ConeRadius, 32 | height = ConeHeight, 33 | topRadius = 0.001f 34 | }) 35 | .transform; 36 | 37 | _collision = 38 | fun.meshes.CreateSphere(new DtSphere {radius = 0.025,name = "collision"}) 39 | .SetStandardShaderTransparentColor(1,0,0,0.9).transform; 40 | 41 | 42 | //_lineEnd1.position = V3(-0.03,0.5,-0.029); 43 | //_lineEnd2.position = V3(0,1.187,0.016); 44 | _lineEnd1.position = V3(-0.03,0.762,-0.248); 45 | _lineEnd2.position = V3(0,0.134,0.016); 46 | } 47 | void Update() 48 | { 49 | //if(_test) return; 50 | //_test = true; 51 | var coneBase = _cone.position; 52 | var coneUp = _cone.up; 53 | var l1 = _lineEnd1.position; 54 | var l2 = _lineEnd2.position; 55 | // test code STARTS here ----------------------------------------------- 56 | 57 | Vector3 collision; 58 | var hasCollision = 59 | fun.intersection.BetweenLineSegmentAndCone( 60 | in l1, in l2, in coneBase, in coneUp, ConeRadius, ConeHeight, out collision); 61 | // test code ENDS here ------------------------------------------------- 62 | if (!hasCollision) collision = Vector3.one*9999; 63 | 64 | _collision.position = collision; 65 | 66 | Debug.DrawLine(l1,l2,hasCollision?Color.green:Color.red,0,false); 67 | 68 | SetColorOnChanged(hasCollision, rgba(0, 1, 0, 0.5), rgba(0.5,0.5,0.5,0.5), _cone); 69 | } 70 | 71 | //private bool _test; 72 | } 73 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/MiscTests/Test2D3DConversion.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Main.MiscTests 7 | { 8 | public class Test2D3DConversion : BaseMainScript 9 | { 10 | private Transform _point1, _point2, _point3; 11 | 12 | // Drag the white ball in Scene view 13 | void Start () 14 | { 15 | const float pointSize = 0.025f; 16 | CreateTriangle(pointSize); 17 | 18 | _point1 = 19 | fun.meshes.CreateSphere(new DtSphere {radius = pointSize}) 20 | .SetStandardShaderTransparentColor(1,0,0,0.9).transform; 21 | _point2 = 22 | fun.meshes.CreateSphere(new DtSphere {radius = pointSize}) 23 | .SetStandardShaderTransparentColor(0,1,0,0.9).transform; 24 | _point3 = 25 | fun.meshes.CreateSphere(new DtSphere {radius = pointSize}) 26 | .SetStandardShaderTransparentColor(0,0,1,0.9).transform; 27 | 28 | 29 | _point1.position += Vector3.forward*0.5f; 30 | _point2.position += Vector3.forward*0.5f+Vector3.up*0.2f; 31 | _point3.position += Vector3.forward*0.5f+Vector3.up*0.2f+Vector3.right*0.2f; 32 | } 33 | 34 | // Update is called once per frame 35 | void Update () 36 | { 37 | Vector3 a, b, c, planeNormal; 38 | SetTriangle(out a, out b, out c, out planeNormal); 39 | 40 | var p1 = _point1.position; 41 | var p2 = _point2.position; 42 | var p3 = _point3.position; 43 | 44 | // test code STARTS here ----------------------------------------------- 45 | Vector3 xAxis2d,yAxis2d; 46 | fun.vector.ComputeRandomXYAxesForPlane(in planeNormal, out xAxis2d, out yAxis2d); 47 | 48 | // we take point "a" to be the origin 49 | var p1in2d = p1.As2d(in a, in xAxis2d, in yAxis2d); 50 | var p2in2d = p2.As2d(in a, in xAxis2d, in yAxis2d); 51 | var p3in2d = p3.As2d(in a, in xAxis2d, in yAxis2d); 52 | 53 | var p1Proj = p1in2d.As3d(in a, in xAxis2d, in yAxis2d); 54 | var p2Proj = p2in2d.As3d(in a, in xAxis2d, in yAxis2d); 55 | var p3Proj = p3in2d.As3d(in a, in xAxis2d, in yAxis2d); 56 | 57 | 58 | // test code ENDS here ------------------------------------------------- 59 | 60 | Debug.DrawLine(p1in2d,p2in2d,Color.black,0,false); 61 | Debug.DrawLine(p2in2d,p3in2d,Color.black,0,false); 62 | Debug.DrawLine(p3in2d,p1in2d,Color.black,0,false); 63 | 64 | Debug.DrawLine(p1,p1Proj,Color.red,0,false); 65 | Debug.DrawLine(p2,p2Proj,Color.green,0,false); 66 | Debug.DrawLine(p3,p3Proj,Color.blue,0,false); 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/TimeRange.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using UnityEngine; 3 | 4 | namespace UnityFunctions 5 | { 6 | internal class TimeRange 7 | { 8 | 9 | private float _interval; 10 | internal TimeRange() : this(0, 0) { } 11 | internal TimeRange(double from, double to) 12 | { 13 | From = (float)from; 14 | To = (float)to; 15 | _interval = To - From; 16 | } 17 | public float From { get; set; } 18 | public float To { get; set; } 19 | internal bool IsCyclical { get; set; } 20 | internal TimeRange SetAsCyclical() 21 | { 22 | IsCyclical = true; 23 | return this; 24 | } 25 | internal TimeRange SetTime(double secondsAfterNow) 26 | { 27 | _interval = (float)secondsAfterNow; 28 | From = Time.time; 29 | To = From + (float)secondsAfterNow; 30 | return this; 31 | } 32 | internal TimeRange SetZero() 33 | { 34 | To = From = 0f; 35 | _interval = 0; 36 | return this; 37 | } 38 | internal float Progress() 39 | { 40 | var now = Time.time; 41 | if (IsCyclical && To < now) 42 | { 43 | var all = To - From; 44 | if (all.IsZero()) 45 | { 46 | return now < From ? 0 : 1; 47 | } 48 | var curr = now - From; 49 | return curr / all; 50 | } 51 | return Progress(now); 52 | } 53 | internal float Progress(float value) 54 | { 55 | return (float)ProgressByValue(From, To, value); 56 | } 57 | private static double ProgressByValue(double from, double to, double value) 58 | { 59 | var all = to - from; 60 | if (all < 0.000001 && all > -0.000001) 61 | { 62 | return value < from ? 0 : 1; 63 | } 64 | var curr = value - from; 65 | return (curr / all); 66 | } 67 | internal bool IsFinished() 68 | { 69 | if (IsCyclical) return false; // cyclicals are never finished 70 | return To <= Time.time; 71 | } 72 | internal bool IsFinishedReset() 73 | { 74 | if (IsCyclical) return false; // cyclicals are never finished 75 | var finished = To <= Time.time; 76 | if (finished) 77 | { 78 | Reset(); 79 | } 80 | return finished; 81 | } 82 | internal TimeRange Reset() 83 | { 84 | SetTime(_interval); 85 | return this; 86 | } 87 | public override string ToString() { return "{type:'TimeRange',from:" + From + ",to:" + To + "}"; } 88 | } 89 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Extensions/IntExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Text; 4 | 5 | namespace Extensions 6 | { 7 | internal static class IntExtensions 8 | { 9 | internal static DateTime FromUnixTimestamp(this long stamp) 10 | { 11 | var dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc); 12 | return dtDateTime.AddSeconds(stamp); 13 | } 14 | internal static string PrefixZero(this int i, int length) 15 | { 16 | return i.ToString().PadLeft(length, '0'); 17 | } 18 | internal static string ToLabel(this int num) 19 | { 20 | var sign = num >= 0 ? "" : "-"; 21 | var abs = num < 0 ? num * -1 : num; 22 | if (abs < 999) return sign + abs; 23 | var numToStr = abs.ToString(CultureInfo.InvariantCulture); 24 | var j = 0; 25 | var sb = new StringBuilder(); 26 | 27 | for (var i = numToStr.Length - 1; i >= 0; --i) 28 | { 29 | var curr = numToStr[i]; 30 | sb.Insert(0, curr); 31 | ++j; 32 | if (j % 3 == 0 && i != 0) sb.Insert(0, ' '); 33 | } 34 | return sign + sb; 35 | } 36 | 37 | internal static string ToTime(this Int64 n) 38 | { 39 | if (n < 1000) return n + " ms"; 40 | if (n < 60000) return Math.Round(n / 1000.0, 2) + " seconds"; 41 | if (n < 3600000) return Math.Round(n / 60000.0, 2) + " minutes"; 42 | return Math.Round(n / 3600000.0, 2) + " hours"; 43 | } 44 | internal static int Sign(this int i) { return Math.Sign(i); } 45 | internal static bool IsOneOf(this int n, int a) { return n == a; } 46 | internal static bool IsOneOf(this int n, int a, int b) { return n == a || n == b; } 47 | internal static bool IsOneOf(this int n, int a, int b, int c) { return n == a || n == b || n == c; } 48 | internal static bool IsOneOf(this int n, int a, int b, int c, int d) { return n == a || n == b || n == c || n == d; } 49 | // internal static bool IsOneOf(this int n, params int[] args) { return args.Contains(n); } 50 | internal static int Clamp(this int value, int min, int max) 51 | { 52 | if (value < min) 53 | { 54 | value = min; 55 | return value; 56 | } 57 | if (value > max) 58 | { 59 | value = max; 60 | } 61 | return value; 62 | } 63 | internal static int Abs(this int n) 64 | { 65 | return n >= 0 ? n : n * -1; 66 | } 67 | internal static int NoMoreThan(this int a, int b) { return a > b ? b : a; } 68 | internal static int NoLessThan(this int a, int b) { return a < b ? b : a; } 69 | 70 | 71 | } 72 | 73 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Extensions/Vector2Extensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityFunctions; 4 | 5 | namespace Extensions 6 | { 7 | internal static class Vector2Extensions 8 | { 9 | internal static Vector2 MoveTowards(in this Vector2 current, in Vector2 target, double maxDistanceDelta) 10 | { 11 | Vector2 vector2 = target - current; 12 | float magnitude = vector2.magnitude; 13 | if ((double)magnitude <= (double)maxDistanceDelta || (double)magnitude == 0.0) 14 | return target; 15 | return current + vector2 / magnitude * (float)maxDistanceDelta; 16 | } 17 | internal static Vector3 As3d(in this Vector2 v2, Vector3 origin, in Vector3 normalizedX, Vector3 normalizedY) 18 | { 19 | return origin + normalizedX * v2.x + normalizedY * v2.y; 20 | } 21 | internal static Vector3 As3d(in this Vector2 v2, in Vector3 origin, in Vector3 normalizedX, in Vector3 normalizedY) 22 | { 23 | return origin + normalizedX * v2.x + normalizedY * v2.y; 24 | } 25 | internal static void As3d(in this Vector2 v2, in Vector3 origin, in Vector3 normalizedX, in Vector3 normalizedY, out Vector3 result) 26 | { 27 | result = origin + normalizedX * v2.x + normalizedY * v2.y; 28 | } 29 | internal static Vector3 ToV3(in this Vector2 v) 30 | { 31 | return new Vector3(v.x, 0, v.y); 32 | } 33 | internal static Vector3 ToV3(in this Vector2 v, double y) 34 | { 35 | return new Vector3(v.x, (float)y, v.y); 36 | } 37 | internal static bool IsEqual(in this Vector2 a, in Vector2 b) 38 | { 39 | return 40 | a.x.IsEqual(b.x) && 41 | a.y.IsEqual(b.y); 42 | } 43 | internal static bool IsEqual(in this Vector2 a, in Vector2 b, double delta) 44 | { 45 | return 46 | a.x.IsEqual(b.x, delta) && 47 | a.y.IsEqual(b.y, delta); 48 | } 49 | internal static bool Equals(in this Vector2 a, in Vector2 b) 50 | { 51 | return a.x.Equals(b.x) && a.y.Equals(b.y); 52 | } 53 | internal static Vector2 GoTowards(in this Vector2 from, in Vector2 to, double stepDistance) 54 | { 55 | if (stepDistance < 0) stepDistance *= -1; 56 | var diff = to - from; 57 | if (diff.magnitude <= stepDistance) return to; 58 | return from + ((float)stepDistance) * diff.normalized; 59 | } 60 | 61 | internal static string s(in this Vector2 v) 62 | { 63 | return v.x.s() + "," + v.y.s(); 64 | } 65 | internal static string s(in this Vector2 v, int digits) 66 | { 67 | return Math.Round(v.x, digits).s() + "," + Math.Round(v.y, digits).s(); 68 | } 69 | } 70 | 71 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/PlaneLineCollision.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Main 7 | { 8 | public class PlaneLineCollision : BaseMainScript 9 | { 10 | private Transform _pointA, _pointB, _projection; 11 | 12 | void Start () 13 | { 14 | const float pointSize = 0.025f; 15 | var dt = new DtTrianglePlane(); 16 | fun.meshes.CreateTwoSidedTrianglePlane(dt).SetStandardShaderTransparentColor(0,0,1,0.5); 17 | _mesh = dt.mesh; 18 | _a = fun.meshes.CreateSphere(new DtSphere {radius = pointSize, name = "Tri_ver_a"}).SetStandardShaderTransparentColor(0,1,0,0.9).transform; 19 | _b = fun.meshes.CreateSphere(new DtSphere {radius = pointSize, name = "Tri_ver_b"}).SetStandardShaderTransparentColor(0,1,0,0.9).transform; 20 | _c = fun.meshes.CreateSphere(new DtSphere {radius = pointSize, name = "Tri_ver_c"}).SetStandardShaderTransparentColor(0,1,0,0.9).transform; 21 | 22 | 23 | _b.position = Vector3.forward*0.5f; 24 | _c.position = Vector3.right*0.5f; 25 | 26 | 27 | _pointA = 28 | fun.meshes.CreateSphere(new DtSphere {radius = pointSize}) 29 | .SetStandardShaderTransparentColor(1,1,0,0.9).transform; 30 | _pointB = 31 | fun.meshes.CreateSphere(new DtSphere {radius = pointSize}) 32 | .SetStandardShaderTransparentColor(1,1,0,0.9).transform; 33 | _projection = 34 | fun.meshes.CreateSphere(new DtSphere {radius = pointSize}) 35 | .SetStandardShaderTransparentColor(1,0,0,0.9).transform; 36 | 37 | _pointA.position = new Vector3(0.5f,0.5f,0.5f); 38 | _pointB.position = new Vector3(0.25f,0.25f,0.25f); 39 | } 40 | 41 | void Update () 42 | { 43 | var a = Vector3.zero; 44 | var b = _b.position; 45 | var c = _c.position; 46 | Vector3 planeNormal; 47 | fun.point.GetNormal(in c, in b, in a, out planeNormal); 48 | 49 | _mesh.vertices = new [] {b,c,a}; 50 | 51 | var line1 = _pointA.position; 52 | var line2 = _pointB.position; 53 | // test code STARTS here ----------------------------------------------- 54 | Vector3 collisionPoint; 55 | var found = fun.intersection.BetweenPlaneAndLine(in planeNormal, in a, 56 | in line1, in line2, out collisionPoint); 57 | 58 | // test code ENDS here ------------------------------------------------- 59 | _projection.position = found ? collisionPoint : V3(0, 10000, 0); 60 | SetColorOnChanged(found,new Color(0,1,0,0.9f),new Color(1,0,0,0.9f),_a,_b,_c); 61 | Debug.DrawLine(line1,line2,Color.yellow); 62 | Debug.DrawLine(line1,collisionPoint,Color.yellow); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/ClosestOnTwoLineSegments.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Main 7 | { 8 | public class ClosestOnTwoLineSegments : BaseMainScript 9 | { 10 | private Transform _collisionA; 11 | private Transform _collisionB; 12 | private Transform _lineEndA1; 13 | private Transform _lineEndA2; 14 | private Transform _lineEndB1; 15 | private Transform _lineEndB2; 16 | 17 | 18 | void Start () 19 | { 20 | 21 | _lineEndA1 = 22 | fun.meshes.CreateSphere(new DtSphere {radius = 0.03, name = "lineA1"}) 23 | .SetStandardShaderTransparentColor(0,1,0,0.9).transform; 24 | _lineEndA1.position = Vector3.forward*-0.5f; 25 | _lineEndA2 = 26 | fun.meshes.CreateSphere(new DtSphere {radius = 0.03, name = "lineA2"}) 27 | .SetStandardShaderTransparentColor(0,1,0,0.9).transform; 28 | _lineEndA2.position = Vector3.forward*0.5f; 29 | 30 | _lineEndB1 = 31 | fun.meshes.CreateSphere(new DtSphere {radius = 0.03, name = "lineB1"}) 32 | .SetStandardShaderTransparentColor(0,0,1,0.9).transform; 33 | _lineEndB1.position = Vector3.forward*-0.5f + Vector3.right*0.2f; 34 | _lineEndB2 = 35 | fun.meshes.CreateSphere(new DtSphere {radius = 0.03, name = "lineB2"}) 36 | .SetStandardShaderTransparentColor(0,0,1,0.9).transform; 37 | _lineEndB2.position = Vector3.forward*0.5f + Vector3.right*0.2f; 38 | 39 | 40 | _collisionA = 41 | fun.meshes.CreateSphere(new DtSphere {radius = 0.05, name = "collisionA"}) 42 | .SetStandardShaderTransparentColor(1,0,0,0.3).transform; 43 | _collisionB = 44 | fun.meshes.CreateSphere(new DtSphere {radius = 0.05, name = "collisionB"}) 45 | .SetStandardShaderTransparentColor(1,1,0,0.3).transform; 46 | 47 | _collisionA.position = _collisionB.position = Vector3.one*1000; 48 | } 49 | void Update() 50 | { 51 | var lA1 = _lineEndA1.position; 52 | var lA2 = _lineEndA2.position; 53 | 54 | var lB1 = _lineEndB1.position; 55 | var lB2 = _lineEndB2.position; 56 | 57 | // test code STARTS here ----------------------------------------------- 58 | Vector3 cpA,cpB; 59 | fun.point.ClosestOnTwoLineSegments(in lA1, in lA2, in lB1, in lB2, out cpA, out cpB); 60 | // test code ENDS here ------------------------------------------------- 61 | Debug.DrawLine(lA1,lA2,Color.green,0,false); 62 | Debug.DrawLine(lB1,lB2,Color.blue,0,false); 63 | 64 | Debug.DrawLine(cpA,cpB,Color.black,0,false); 65 | _collisionA.position = cpA; 66 | _collisionB.position = cpB; 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Extensions/MaterialExtensions.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Extensions 4 | { 5 | internal static class MaterialExtensions 6 | { 7 | internal static Material SetStandardShaderRenderingModeOpaque(this Material material) 8 | { 9 | material.SetFloat("_Mode", 0f); 10 | material.SetOverrideTag("RenderType", ""); 11 | material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); 12 | material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero); 13 | material.SetInt("_ZWrite", 1); 14 | material.DisableKeyword("_ALPHATEST_ON"); 15 | material.DisableKeyword("_ALPHABLEND_ON"); 16 | material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); 17 | material.renderQueue = -1; 18 | return material; 19 | } 20 | internal static Material SetStandardShaderRenderingModeCutout(this Material material) 21 | { 22 | material.SetFloat("_Mode", 1f); 23 | material.SetOverrideTag("RenderType", "TransparentCutout"); 24 | material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); 25 | material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero); 26 | material.SetInt("_ZWrite", 1); 27 | material.EnableKeyword("_ALPHATEST_ON"); 28 | material.DisableKeyword("_ALPHABLEND_ON"); 29 | material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); 30 | material.renderQueue = 2450; 31 | return material; 32 | } 33 | internal static Material SetStandardShaderRenderingModeFade(this Material material) 34 | { 35 | material.SetFloat("_Mode", 2f); 36 | material.SetOverrideTag("RenderType", "Transparent"); 37 | material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha); 38 | material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); 39 | material.SetInt("_ZWrite", 0); 40 | material.DisableKeyword("_ALPHATEST_ON"); 41 | material.EnableKeyword("_ALPHABLEND_ON"); 42 | material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); 43 | material.renderQueue = 3000; 44 | return material; 45 | } 46 | internal static Material SetStandardShaderRenderingModeTransparent(this Material material) 47 | { 48 | material.SetFloat("_Mode", 3f); 49 | material.SetOverrideTag("RenderType", "Transparent"); 50 | material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); 51 | material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); 52 | material.SetInt("_ZWrite", 0); 53 | material.DisableKeyword("_ALPHATEST_ON"); 54 | material.DisableKeyword("_ALPHABLEND_ON"); 55 | material.EnableKeyword("_ALPHAPREMULTIPLY_ON"); 56 | material.renderQueue = 3000; 57 | return material; 58 | } 59 | 60 | } 61 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/v3.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Unianio 4 | { 5 | internal static class v3 6 | { 7 | /// 8 | /// 0, 0, 0 9 | /// 10 | internal static Vector3 zero = new Vector3(0, 0, 0); 11 | /// 12 | /// 1, 1, 1 13 | /// 14 | internal static Vector3 one = new Vector3(1, 1, 1); 15 | /// 16 | /// 1, 0, 0 17 | /// 18 | internal static Vector3 unitX = new Vector3(1, 0, 0); 19 | /// 20 | /// 0, 1, 0 21 | /// 22 | internal static Vector3 unitY = new Vector3(0, 1, 0); 23 | /// 24 | /// 0, 0, 1 25 | /// 26 | internal static Vector3 unitZ = new Vector3(0, 0, 1); 27 | /// 28 | /// -1, 0, 0 29 | /// 30 | internal static Vector3 unitMinX = new Vector3(-1, 0, 0); 31 | /// 32 | /// 0, -1, 0 33 | /// 34 | internal static Vector3 unitMinY = new Vector3(0, -1, 0); 35 | /// 36 | /// 0, 0, -1 37 | /// 38 | internal static Vector3 unitMinZ = new Vector3(0, 0, -1); 39 | /// 40 | /// 0, 0, 1 41 | /// 42 | internal static Vector3 forward = Vector3.forward; 43 | /// 44 | /// 0, 0, 1 45 | /// 46 | internal static Vector3 fw = Vector3.forward; 47 | /// 48 | /// 0, 0, -1 49 | /// 50 | internal static Vector3 back = Vector3.back; 51 | /// 52 | /// 0, 0, -1 53 | /// 54 | internal static Vector3 bk = Vector3.back; 55 | /// 56 | /// -1, 0, 0 57 | /// 58 | internal static Vector3 left = Vector3.left; 59 | /// 60 | /// -1, 0, 0 61 | /// 62 | internal static Vector3 lt = Vector3.left; 63 | /// 64 | /// 1, 0, 0 65 | /// 66 | internal static Vector3 right = Vector3.right; 67 | /// 68 | /// 1, 0, 0 69 | /// 70 | internal static Vector3 rt = Vector3.right; 71 | /// 72 | /// 0, 1, 0 73 | /// 74 | internal static Vector3 up = Vector3.up; 75 | /// 76 | /// 0, -1, 0 77 | /// 78 | internal static Vector3 down = Vector3.down; 79 | /// 80 | /// 0, -1, 0 81 | /// 82 | internal static Vector3 dn = Vector3.down; 83 | /// 84 | /// float.NaN, float.NaN, float.NaN 85 | /// 86 | internal static Vector3 nan = new Vector3(float.NaN, float.NaN, float.NaN); 87 | /// 88 | /// 99999, 99999, 99999 89 | /// 90 | internal static Vector3 far = new Vector3(99999, 99999, 99999); 91 | } 92 | 93 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Visualization of different unity projection and collistion detection algorithms 2 | 3 | [![Unity 3D manual collisions](https://img.youtube.com/vi/1xbVyvCTEwU/0.jpg)](https://www.youtube.com/watch?v=1xbVyvCTEwU) 4 | 5 | How to: 6 | 7 | 1. Open scene from unity-functions/UnityFunctions/Assets/Scenes/ folder. 8 | 9 | 2. Play the scene 10 | 11 | 3. Open "Scene View" then select object and move it. 12 | 13 | When screen object is selected you can use shortcuts to switch between views: 14 | 15 | * W - move 16 | * E - rotate 17 | 18 | main behaviours for each collision are in **unity-functions\UnityFunctions\Assets\Scripts\Main** 19 | 20 | ## Collisions Visualized: 21 | 22 | * Capsule - Capsule: [CapsuleCapsuleCollision.cs](https://github.com/vbodurov/unity-functions/blob/master/UnityFunctions/Assets/Scripts/Main/CapsuleCapsuleCollision.cs) 23 | * Capsule - Disk: [CapsuleDiskCollision.cs](https://github.com/vbodurov/unity-functions/blob/master/UnityFunctions/Assets/Scripts/Main/CapsuleDiskCollision.cs) 24 | * Capsule - Sphere: [CapsuleSphereCollision.cs](https://github.com/vbodurov/unity-functions/blob/master/UnityFunctions/Assets/Scripts/Main/CapsuleSphereCollision.cs) 25 | * Disk - Disk: [DiskDiskCollision.cs](https://github.com/vbodurov/unity-functions/blob/master/UnityFunctions/Assets/Scripts/Main/DiskDiskCollision.cs) 26 | * Ray - Sphere: [RaySphereCollision.cs](https://github.com/vbodurov/unity-functions/blob/master/UnityFunctions/Assets/Scripts/Main/RaySphereCollision.cs) 27 | * Ray - Triangle:[RayTriangleCollision.cs](https://github.com/vbodurov/unity-functions/blob/master/UnityFunctions/Assets/Scripts/Main/RayTriangleCollision.cs) 28 | * Triangle - Disk: [TriangleDiskCollision.cs](https://github.com/vbodurov/unity-functions/blob/master/UnityFunctions/Assets/Scripts/Main/TriangleDiskCollision.cs) 29 | * Triangle - Line: [TriangleLineCollision.cs](https://github.com/vbodurov/unity-functions/blob/master/UnityFunctions/Assets/Scripts/Main/TriangleLineCollision.cs) 30 | * Triangle - Sphere: [TriangleSphereCollision.cs](https://github.com/vbodurov/unity-functions/blob/master/UnityFunctions/Assets/Scripts/Main/TriangleSphereCollision.cs) 31 | * Triangle - Triangle: [TriangleTriangleCollision.cs](https://github.com/vbodurov/unity-functions/blob/master/UnityFunctions/Assets/Scripts/Main/TriangleTriangleCollision.cs) 32 | 33 | ## Projecting on a Plane: 34 | 35 | * Project point on a plane [ProjectPointOnPlane.cs](https://github.com/vbodurov/unity-functions/blob/master/UnityFunctions/Assets/Scripts/Main/ProjectPointOnPlane.cs) 36 | * Project vector on a plane [ProjectVectorOnPlane.cs](https://github.com/vbodurov/unity-functions/blob/master/UnityFunctions/Assets/Scripts/Main/ProjectVectorOnPlane.cs) 37 | 38 | ## Transforming Spaces: 39 | 40 | * Between Local and World without Transform [TestComputeRelative.cs](https://github.com/vbodurov/unity-functions/blob/master/UnityFunctions/Assets/Scripts/Main/MiscTests/TestComputeRelative.cs) 41 | * Between 2D and 3D [Test2D3DConversion.cs](https://github.com/vbodurov/unity-functions/blob/master/UnityFunctions/Assets/Scripts/Main/MiscTests/Test2D3DConversion.cs) 42 | 43 | ## Miscellaneous: 44 | 45 | * More Than 360 Degrees Rotation [TestMoreThan360Rotation.cs](https://github.com/vbodurov/unity-functions/blob/master/UnityFunctions/Assets/Scripts/Main/MiscTests/TestMoreThan360Rotation.cs) 46 | 47 | 48 | -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/RelativeRotationDistribution.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Main 7 | { 8 | public class RelativeRotationDistribution : BaseMainScript 9 | { 10 | private Transform _arm,_wrist,_finger1,_finger2,_finger3, _control; 11 | private Quaternion _origLocRotFin1,_origLocRotFin2,_origLocRotFin3; 12 | 13 | void Start () 14 | { 15 | _arm = CreateJoin(9,0,0,1); 16 | _arm.position = Vector3.zero; 17 | _wrist = CreateJoin(2,0,1,0); 18 | _wrist.position = V3(0,0,1); 19 | _wrist.SetParent(_arm); 20 | _finger1 = CreateJoin(2,1,0,0); 21 | _finger1.position = V3(0,0,1.2); 22 | _finger1.rotation = Quaternion.LookRotation(Vector3.Slerp(Vector3.forward, Vector3.right, 0.5f), Vector3.up); 23 | _finger1.SetParent(_wrist); 24 | _finger2 = CreateJoin(2,1,0,0); 25 | _finger2.position = V3(0,0,1.2); 26 | _finger2.rotation = Quaternion.LookRotation(Vector3.forward, Vector3.up); 27 | _finger2.SetParent(_wrist); 28 | _finger3 = CreateJoin(2,1,0,0); 29 | _finger3.position = V3(0,0,1.2); 30 | _finger3.rotation = Quaternion.LookRotation(Vector3.Slerp(Vector3.forward, Vector3.left, 0.5f), Vector3.up); 31 | _finger3.SetParent(_wrist); 32 | 33 | _origLocRotFin1 = _finger1.localRotation; 34 | _origLocRotFin2 = _finger2.localRotation; 35 | _origLocRotFin3 = _finger3.localRotation; 36 | 37 | _control = 38 | fun.meshes.CreateBox(new DtBox {side = 0.1}) 39 | .SetStandardShaderTransparentColor(1,1,1,0.5).transform; 40 | _control.position = _finger2.position; 41 | _control.rotation = Quaternion.LookRotation(Vector3.forward, Vector3.up); 42 | _control.SetParent(_arm); 43 | } 44 | 45 | void Update () 46 | { 47 | var controlFw = _control.forward; 48 | var controlUp = _control.up; 49 | 50 | var targetRot = Quaternion.LookRotation(controlFw, controlUp); 51 | var halfRot = Quaternion.Slerp(_arm.rotation, targetRot, 0.5f); 52 | _wrist.rotation = halfRot; 53 | 54 | var restOfRot = 55 | (Quaternion.Inverse(_wrist.rotation) * Quaternion.LookRotation(controlFw, controlUp)); 56 | 57 | _finger1.localRotation = restOfRot * _origLocRotFin1; 58 | _finger2.localRotation = restOfRot * _origLocRotFin2; 59 | _finger3.localRotation = restOfRot * _origLocRotFin3; 60 | // _finger1.localRotation = _origLocRotFin1 * relRot; 61 | // _finger2.localRotation = _origLocRotFin2 * relRot; 62 | // _finger3.localRotation = _origLocRotFin3 * relRot; 63 | 64 | } 65 | 66 | private Transform CreateJoin(double noseLen, double red, double green, double blue) 67 | { 68 | var join = 69 | fun.meshes.CreatePointyCone(new DtCone {height = 0.1,bottomRadius = 0.1,topRadius = 0.001f, relNoseLen = noseLen}) 70 | .SetStandardShaderTransparentColor(red,green,blue,0.75).transform; 71 | join.hideFlags = HideFlags.HideInHierarchy | HideFlags.NotEditable; 72 | return join; 73 | } 74 | 75 | 76 | } 77 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/FingerInverseKinematics.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | using Utils; 6 | 7 | namespace Main 8 | { 9 | public class FingerInverseKinematics : BaseMainScript 10 | { 11 | Transform _origin,_target,_join1,_join2,_join3; 12 | Vector3[] _points; 13 | float[] _lengths; 14 | int _i; 15 | 16 | const double len1 = 0.30; 17 | const double len2 = 0.20; 18 | const double len3 = 0.10; 19 | 20 | 21 | void Start () 22 | { 23 | _lengths = new[] { (float)len1, (float)len2, (float)len3 }; 24 | _points = new[] { Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero }; 25 | 26 | _origin = 27 | fun.meshes.CreatePointyCone(new DtCone {height = 0.05,bottomRadius = 0.05,topRadius = 0.001f}) 28 | .SetStandardShaderTransparentColor(1,0,1,0.5).transform; 29 | _origin.position += Vector3.forward*-0.5f; 30 | 31 | _join1 = CreateJoin(1, len1, 1, 0, 0); 32 | _join2 = CreateJoin(2, len2, 0, 1, 0); 33 | _join3 = CreateJoin(3, len3, 0, 0, 1); 34 | 35 | _join1.position = _origin.position; 36 | _join2.position = _join1.position + _origin.forward * (float)len1; 37 | _join3.position = _join2.position + _origin.forward * (float)len2; 38 | 39 | _target = fun.meshes.CreateBox(new DtBox {side = 0.05}).transform; 40 | //_target.position += Vector3.forward*0.5f; 41 | _i = 0; 42 | } 43 | 44 | void Update () 45 | { 46 | ++_i; 47 | var tarPo = _target.position; 48 | var oriPo = _origin.position; 49 | var oriUp = _origin.up; 50 | var oriFw = _origin.forward; 51 | 52 | // if(_i > 1) return; 53 | // test code STARTS here ----------------------------------------------- 54 | Vector3 j0, j1, norm; 55 | fun.inverseKinematics.Finger(oriPo, oriFw, oriUp, tarPo, _points,_lengths, out j0, out j1, out norm); 56 | // test code ENDS here ------------------------------------------------- 57 | 58 | var toJ0 = (j0 - oriPo).normalized; 59 | var toJ1 = (j1 - j0).normalized; 60 | var toTarg = (tarPo - j1).normalized; 61 | 62 | _join1.rotation = Quaternion.LookRotation(toJ0, norm); 63 | 64 | _join2.rotation = Quaternion.LookRotation(toJ1, toJ1.GetRealUp(_join1.rotation * Vector3.up, _join1.rotation * Vector3.forward)); 65 | _join2.position = j0; 66 | 67 | _join3.rotation = Quaternion.LookRotation(toTarg, toTarg.GetRealUp(_join2.rotation * Vector3.up, _join2.rotation * Vector3.forward)); 68 | _join3.position = j1; 69 | } 70 | 71 | private Transform CreateJoin(int id, double len, double red, double green, double blue) 72 | { 73 | var join = 74 | fun.meshes.CreatePointyCone(new DtCone { height = len, bottomRadius = 0.02, topRadius = 0.001f, relNoseLen = 2 }) 75 | .SetStandardShaderTransparentColor(red,green,blue,0.5).transform; 76 | join.gameObject.hideFlags = HideFlags.HideInHierarchy; 77 | var wrapper = new GameObject(join.name+"_wrapper"); 78 | join.SetParent(wrapper.transform); 79 | join.transform.localRotation = Quaternion.Euler(90,0,0); 80 | join.transform.localPosition = new Vector3(0,0,0); 81 | return wrapper.transform; 82 | } 83 | 84 | 85 | } 86 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/TwoJoinsInverseKinematics.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | using Utils; 6 | 7 | namespace Main 8 | { 9 | public class TwoJoinsInverseKinematics : BaseMainScript 10 | { 11 | private Transform _origin,_target,_join1,_join2; 12 | 13 | const double len1 = 0.30; 14 | const double len2 = 0.20; 15 | 16 | const double capRad = 0.01; 17 | 18 | void Start () 19 | { 20 | 21 | _origin = 22 | fun.meshes.CreatePointyCone(new DtCone {height = 0.05,bottomRadius = 0.05,topRadius = 0.001f}) 23 | .SetStandardShaderTransparentColor(1,0,1,0.5).transform; 24 | _origin.position += Vector3.forward*-0.5f; 25 | 26 | _join1 = CreateJoin(1,len1,1,0,0); 27 | _join2 = CreateJoin(2,len2,0,1,0); 28 | 29 | _join1.position = _origin.position; 30 | _join2.position = _join1.position + _origin.forward * (float)len1; 31 | 32 | _target = fun.meshes.CreateBox(new DtBox {side = 0.05}).transform; 33 | _target.position += Vector3.forward*0.5f; 34 | } 35 | 36 | void Update () 37 | { 38 | var tarPo = _target.position; 39 | var oriPo = _origin.position; 40 | var oriUp = _origin.up; 41 | var oriFw = _origin.forward; 42 | 43 | // test code STARTS here ----------------------------------------------- 44 | // var distToPlane = 45 | // fun.point.IsBelowPlane(ref tarPo, ref oriFw, ref oriPo) 46 | // ? 0 47 | // : fun.point.DistanceToPlane(ref tarPo, ref oriFw, ref oriPo); 48 | // 49 | // var lenAll = (float)(len1+len2+len1); 50 | // var relDistToPlane = distToPlane / lenAll; 51 | // Vector3 oriRt; 52 | // fun.vector.GetNormal(ref oriFw, ref oriUp, out oriRt); 53 | // Vector3 tarPoOnPlane; 54 | // fun.point.ProjectOnPlane(ref tarPo, ref oriRt, ref oriPo, out tarPoOnPlane); 55 | // tarPo = Vector3.Lerp(tarPoOnPlane, tarPo, (float)BezierFunc.GetY(relDistToPlane, 0.20,0.00,0.00,1.00)); 56 | 57 | Vector3 join; 58 | fun.inverseKinematics.TwoJoinsOnVertPlane(oriPo, oriFw, oriUp, tarPo, len1, len2, out join); 59 | // test code ENDS here ------------------------------------------------- 60 | 61 | var toJ0 = (join - oriPo).normalized; 62 | var toTarg = (tarPo - join).normalized; 63 | 64 | _join1.rotation = Quaternion.LookRotation(toJ0, toJ0.GetRealUp(oriUp, oriFw)); 65 | _join2.rotation = Quaternion.LookRotation(toTarg, toTarg.GetRealUp(_join1.rotation*Vector3.up,_join1.rotation*Vector3.forward)); 66 | _join2.position = join; 67 | } 68 | 69 | private Transform CreateJoin(int id, double len, double red, double green, double blue) 70 | { 71 | var join = 72 | fun.meshes.CreateCapsule(new DtCapsule {height = len-capRad*2, name="join_"+id, radius = capRad}) 73 | .SetStandardShaderTransparentColor(red,green,blue,0.5).transform; 74 | join.gameObject.hideFlags = HideFlags.HideInHierarchy; 75 | var wrapper = new GameObject(join.name+"_wrapper"); 76 | join.SetParent(wrapper.transform); 77 | join.transform.localRotation = Quaternion.Euler(90,0,0); 78 | join.transform.localPosition = new Vector3(0,0,(float)len/2f); 79 | return wrapper.transform; 80 | } 81 | 82 | 83 | } 84 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Extensions/ColliderExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Extensions 7 | { 8 | internal static class ColliderExtensions 9 | { 10 | internal static Vector3 ClosestToSurfacePoint(this Collider collider, Vector3 point, bool throwIfFallback = true) 11 | { 12 | var sc = collider as SphereCollider; 13 | if(sc != null) 14 | { 15 | var closest = sc.ClosestPoint(point); 16 | if(fun.distanceSquared.Between(in closest, in point) < 0.001) 17 | { 18 | var toPointDir = (point - sc.transform.position).ToUnit(Vector3.forward); 19 | closest = sc.ClosestPoint(sc.transform.position + toPointDir*(sc.radius+0.001f)); 20 | } 21 | return closest; 22 | } 23 | var cc = collider as CapsuleCollider; 24 | if(cc != null) 25 | { 26 | var closest = cc.ClosestPoint(point); 27 | if(fun.distanceSquared.Between(in closest, in point) < 0.001) 28 | { 29 | var dir = cc.direction == 0 ? new Vector3(1,0,0) : cc.direction == 1 ? new Vector3(0,1,0) : new Vector3(0,0,1); 30 | 31 | var vec = (cc.transform.rotation * dir) * (cc.height/2f - cc.radius); 32 | var c1 = cc.transform.position + vec; 33 | var c2 = cc.transform.position - vec; 34 | Vector3 drop; 35 | fun.point.ClosestOnLineSegment(in point, in c1, in c2, out drop); 36 | var toPointDir = (point - drop).ToUnit(Vector3.forward); 37 | closest = cc.ClosestPoint(drop + toPointDir*(cc.radius+0.001f)); 38 | } 39 | return closest; 40 | } 41 | if(throwIfFallback) throw new ArgumentException("Unsupported collider type "+collider); 42 | return collider.ClosestPoint(point); 43 | } 44 | 45 | internal static void ClosestToSurfacePointAndNormal(this Collider collider, ref Vector3 point, out Vector3 onSurface, out Vector3 normal, out bool isOnSurfaceOrInside) 46 | { 47 | isOnSurfaceOrInside = false; 48 | var sc = collider as SphereCollider; 49 | if(sc != null) 50 | { 51 | onSurface = sc.ClosestPoint(point); 52 | normal = (point - sc.transform.position).ToUnit(Vector3.forward); 53 | if(fun.distanceSquared.Between(in onSurface, in point) < 0.001) 54 | { 55 | onSurface = sc.ClosestPoint(sc.transform.position + normal*(sc.radius+0.001f)); 56 | isOnSurfaceOrInside = true; 57 | } 58 | return; 59 | } 60 | var cc = collider as CapsuleCollider; 61 | if(cc != null) 62 | { 63 | var pos = cc.transform.position; 64 | onSurface = cc.ClosestPoint(point); 65 | var dir = cc.direction == 0 ? new Vector3(1,0,0) : cc.direction == 1 ? new Vector3(0,1,0) : new Vector3(0,0,1); 66 | var vec = (cc.transform.rotation * dir) * (cc.height/2f - cc.radius); 67 | var c1 = pos + vec; 68 | var c2 = pos - vec; 69 | Vector3 drop; 70 | fun.point.ClosestOnLineSegment(in point, in c1, in c2, out drop); 71 | normal = (point - drop).ToUnit(Vector3.forward); 72 | if(fun.distanceSquared.Between(in onSurface, in point) < 0.001) 73 | { 74 | onSurface = cc.ClosestPoint(drop + normal*(cc.radius+0.001f)); 75 | isOnSurfaceOrInside = true; 76 | } 77 | return; 78 | } 79 | throw new ArgumentException("Unsupported collider type "+collider); 80 | } 81 | 82 | 83 | internal static bool IsPointOnSurfaceOrInside(this Collider collider, Vector3 point) 84 | { 85 | var closest = collider.ClosestPoint(point); 86 | return fun.distanceSquared.Between(in closest, in point) < 0.0001; 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/ThreeJoinsInverseKinematics.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | using Utils; 6 | 7 | namespace Main 8 | { 9 | public class ThreeJoinsInverseKinematics : BaseMainScript 10 | { 11 | private Transform _origin,_target,_join1,_join2,_join3; 12 | 13 | const double len1 = 0.30; 14 | const double len2 = 0.20; 15 | 16 | const double capRad = 0.01; 17 | 18 | void Start () 19 | { 20 | 21 | _origin = 22 | fun.meshes.CreatePointyCone(new DtCone {height = 0.05,bottomRadius = 0.05,topRadius = 0.001f}) 23 | .SetStandardShaderTransparentColor(1,0,1,0.5).transform; 24 | _origin.position += Vector3.forward*-0.5f; 25 | 26 | _join1 = CreateJoin(1,len1,1,0,0); 27 | _join2 = CreateJoin(2,len2,0,1,0); 28 | _join3 = CreateJoin(3,len1,0,0,1); 29 | 30 | _join1.position = _origin.position; 31 | _join2.position = _join1.position + _origin.forward * (float)len1; 32 | _join3.position = _join2.position + _origin.forward * (float)len2; 33 | 34 | _target = fun.meshes.CreateBox(new DtBox {side = 0.05}).transform; 35 | _target.position += Vector3.forward*0.5f; 36 | } 37 | 38 | void Update () 39 | { 40 | var tarPo = _target.position; 41 | var oriPo = _origin.position; 42 | var oriUp = _origin.up; 43 | var oriFw = _origin.forward; 44 | 45 | // test code STARTS here ----------------------------------------------- 46 | var distToPlane = 47 | fun.point.IsBelowPlane(in tarPo, in oriFw, in oriPo) 48 | ? 0 49 | : fun.point.DistanceToPlane(in tarPo, in oriFw, in oriPo); 50 | 51 | var lenAll = (float)(len1+len2+len1); 52 | var relDistToPlane = distToPlane / lenAll; 53 | Vector3 oriRt; 54 | fun.vector.GetNormal(in oriFw, in oriUp, out oriRt); 55 | Vector3 tarPoOnPlane; 56 | fun.point.ProjectOnPlane(in tarPo, in oriRt, in oriPo, out tarPoOnPlane); 57 | tarPo = Vector3.Lerp(tarPoOnPlane, tarPo, (float)BezierFunc.GetY(relDistToPlane, 0.20,0.00,0.00,1.00)); 58 | 59 | 60 | Vector3 j0, j1; 61 | fun.inverseKinematics.ThreeJoinOnVertPlane(oriPo, oriFw, oriUp, tarPo, len1, len2, out j0, out j1); 62 | // test code ENDS here ------------------------------------------------- 63 | 64 | var toJ0 = (j0 - oriPo).normalized; 65 | var toJ1 = (j1 - j0).normalized; 66 | var toTarg = (tarPo - j1).normalized; 67 | 68 | _join1.rotation = Quaternion.LookRotation(toJ0, toJ0.GetRealUp(oriUp, oriFw)); 69 | Debug.DrawLine(_join1.position+Vector3.one*0.02f,_join1.position+Vector3.one*0.02f+oriFw*1f, Color.blue); 70 | Debug.DrawLine(_join1.position+Vector3.one*0.02f,_join1.position+Vector3.one*0.02f+oriUp*1f, Color.green); 71 | 72 | Debug.DrawLine(_join1.position,_join1.position+_join1.forward*0.1f, Color.blue); 73 | Debug.DrawLine(_join1.position,_join1.position+_join1.up*0.1f, Color.green); 74 | _join2.rotation = Quaternion.LookRotation(toJ1, toJ1.GetRealUp(_join1.rotation*Vector3.up,_join1.rotation*Vector3.forward)); 75 | _join2.position = j0; 76 | 77 | _join3.rotation = Quaternion.LookRotation(toTarg, toTarg.GetRealUp(_join2.rotation*Vector3.up,_join2.rotation*Vector3.forward)); 78 | _join3.position = j1; 79 | } 80 | 81 | private Transform CreateJoin(int id, double len, double red, double green, double blue) 82 | { 83 | var join = 84 | fun.meshes.CreateCapsule(new DtCapsule {height = len-capRad*2, name="join_"+id, radius = capRad}) 85 | .SetStandardShaderTransparentColor(red,green,blue,0.5).transform; 86 | join.gameObject.hideFlags = HideFlags.HideInHierarchy; 87 | var wrapper = new GameObject(join.name+"_wrapper"); 88 | join.SetParent(wrapper.transform); 89 | join.transform.localRotation = Quaternion.Euler(90,0,0); 90 | join.transform.localPosition = new Vector3(0,0,(float)len/2f); 91 | return wrapper.transform; 92 | } 93 | 94 | 95 | } 96 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/CapsuleCapsuleResolution.cs: -------------------------------------------------------------------------------- 1 | using Extensions; 2 | using Unianio; 3 | using UnityEngine; 4 | using UnityFunctions; 5 | 6 | namespace Main 7 | { 8 | public class CapsuleCapsuleResolution : BaseMainScript 9 | { 10 | // private const float CapsuleRadius1 = 0.12f; 11 | // private const float CapsuleRadius2 = 0.2f; 12 | // private const float CapsuleHeight1 = 0.8f; 13 | // private const float CapsuleHeight2 = 0.6f; 14 | 15 | private const float StaticHeight = 0.4f; 16 | private const float StaticRadius = 0.14f; 17 | 18 | private const float DynamicHeight = 0.8f; 19 | private const float DynamicRadius = 0.06f; 20 | private Transform _static,_dynamicPrev,_dynamicNext; 21 | private GameObject _dynPrev; 22 | private GameObject _dynNext; 23 | 24 | void Start () 25 | { 26 | var statCap = fun.meshes.CreateCapsule( 27 | new DtCapsule {radius = StaticRadius, height = StaticHeight, name = "static_cap"}); 28 | _dynPrev = fun.meshes.CreateCapsule( 29 | new DtCapsule {radius = DynamicRadius, height = DynamicHeight, name = "dynamic_prev_raw"}); 30 | _dynNext = fun.meshes.CreateCapsule( 31 | new DtCapsule {radius = DynamicRadius, height = DynamicHeight, name = "dynamic_next_raw"}); 32 | _dynPrev.hideFlags = HideFlags.HideInHierarchy; 33 | _dynNext.hideFlags = HideFlags.HideInHierarchy; 34 | 35 | 36 | var dynPrevWrapper = new GameObject("dynamic_prev"); 37 | dynPrevWrapper.transform.position = _dynPrev.transform.position + (-_dynPrev.transform.up)*(DynamicHeight/2+DynamicRadius); 38 | dynPrevWrapper.transform.rotation = Quaternion.LookRotation(_dynPrev.transform.up, _dynPrev.transform.forward); 39 | dynPrevWrapper.hideFlags = HideFlags.HideInHierarchy; 40 | _dynPrev.transform.SetParent(dynPrevWrapper.transform); 41 | 42 | var dynNextWrapper = new GameObject("dynamic_next"); 43 | dynNextWrapper.transform.position = _dynNext.transform.position + (-_dynNext.transform.up)*(DynamicHeight/2+DynamicRadius); 44 | dynNextWrapper.transform.rotation = Quaternion.LookRotation(_dynNext.transform.up, _dynNext.transform.forward); 45 | _dynNext.transform.SetParent(dynNextWrapper.transform); 46 | 47 | 48 | _static = statCap.transform; 49 | _dynamicPrev = dynPrevWrapper.transform; 50 | _dynamicPrev.position += Vector3.forward*-0.5f + Vector3.up*0.5f + Vector3.right*0.3f; 51 | _dynamicPrev.rotation = Quaternion.Euler(0,0,180); 52 | _dynamicNext = dynNextWrapper.transform; 53 | _dynamicNext.position = _dynamicPrev.position; 54 | _dynamicNext.rotation = _dynamicPrev.rotation; 55 | 56 | } 57 | void Update() 58 | { 59 | var statP0 = _static.position - _static.up*(StaticHeight/2); 60 | var statP1 = _static.position + _static.up*(StaticHeight/2); 61 | 62 | var prevP0 = _dynamicPrev.position + _dynamicPrev.forward*(DynamicRadius); 63 | var prevP1 = _dynamicPrev.position + _dynamicPrev.forward*(DynamicRadius + DynamicHeight); 64 | 65 | var nextP0 = _dynamicNext.position + _dynamicNext.forward*(DynamicRadius); 66 | var nextP1 = _dynamicNext.position + _dynamicNext.forward*(DynamicRadius + DynamicHeight); 67 | var nextUp = _dynamicNext.up; 68 | 69 | // test code STARTS here ----------------------------------------------- 70 | Vector3 resolvedPos; 71 | Quaternion resolvedRot; 72 | var hasResolution = 73 | fun.resolution.BetweenCapsules( 74 | in statP0, in statP1, StaticRadius, 75 | in prevP0, in prevP1, in nextP0, in nextP1, in nextUp, DynamicRadius, 76 | out resolvedPos, out resolvedRot); 77 | // test code ENDS here ------------------------------------------------- 78 | 79 | _dynamicPrev.position = resolvedPos; 80 | _dynamicPrev.rotation = resolvedRot; 81 | 82 | SetColorOnChanged(hasResolution, rgba(1, 0, 0, 0.5), rgba(0.5,0.0,0.0,0.2), _static); 83 | SetColorOnChanged(hasResolution, rgba(0, 1, 0, 0.5), rgba(0.0,0.5,0.0,0.2), _dynPrev.transform); 84 | SetColorOnChanged(hasResolution, rgba(0, 0, 1, 0.5), rgba(0.0,0.0,0.5,0.2), _dynNext.transform); 85 | } 86 | 87 | 88 | 89 | 90 | 91 | 92 | } 93 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Services/SoftBodyJiggleAgent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Extensions; 3 | using Unianio; 4 | using UnityEngine; 5 | using static Unianio.fun; 6 | 7 | namespace Services 8 | { 9 | internal interface ISoftBodyJiggleAgent 10 | { 11 | (Vector3 position, Quaternion rotation) Compute(); 12 | SoftBodyConfig Config { get; } 13 | } 14 | internal class SoftBodyConfig 15 | { 16 | internal double Stiffness { get; set; } = 0.1; 17 | internal double Mass { get; set; } = 0.9; 18 | internal double Damping { get; set; } = 0.72; 19 | internal double Gravity { get; set; } = 0.72; 20 | internal double MaxDegrees { get; set; } = 50; 21 | internal double MaxStretch { get; set; } = 2; 22 | internal double MaxSqueeze { get; set; } = 1; 23 | internal double RelTargetAt { get; set; } = 0.07; 24 | internal Transform Bone { get; set; } 25 | 26 | } 27 | internal class SoftBodyJiggleAgent : ISoftBodyJiggleAgent 28 | { 29 | readonly IPendulumPhysicsAgent _ppa; 30 | readonly SoftBodyConfig _cfg; 31 | readonly Vector3 _relStaticTarget, _relIniPos, _relIniFw, _relIniUp; 32 | internal SoftBodyJiggleAgent(SoftBodyConfig config) 33 | { 34 | _ppa = new PendulumPhysicsAgent(config.Stiffness, config.Mass, config.Damping, config.Gravity); 35 | _cfg = config ?? new SoftBodyConfig(); 36 | _relStaticTarget = 37 | (_cfg.Bone.position + _cfg.Bone.forward * (float)_cfg.RelTargetAt) 38 | .AsLocalPoint(_cfg.Bone.parent); 39 | _relIniPos = _cfg.Bone.position.AsLocalPoint(_cfg.Bone.parent); 40 | _relIniFw = _cfg.Bone.forward.AsLocalDir(_cfg.Bone.parent); 41 | _relIniUp = _cfg.Bone.up.AsLocalDir(_cfg.Bone.parent); 42 | } 43 | SoftBodyConfig ISoftBodyJiggleAgent.Config => _cfg; 44 | (Vector3 position, Quaternion rotation) ISoftBodyJiggleAgent.Compute() 45 | { 46 | var staticTarget = 47 | _relStaticTarget.AsWorldPoint(_cfg.Bone.parent); 48 | 49 | var iniFw = _relIniFw.AsWorldDir(_cfg.Bone.parent); 50 | 51 | var staticSource = 52 | _relIniPos.AsWorldPoint(_cfg.Bone.parent); 53 | 54 | var gravityFactor01 = 0f; 55 | if (abs(_cfg.Gravity) > 0.0001) 56 | { 57 | var iniUpWo = _relIniUp.AsWorldDir(_cfg.Bone.parent); 58 | gravityFactor01 = dot(in iniUpWo, in v3.dn).FromMin11To01().Clamp01(); 59 | } 60 | 61 | var dynamicTarget = 62 | _ppa.Compute(in staticTarget, gravityFactor01, 63 | (ref Vector3 dynamicPos, ref Vector3 velocity, in Vector3 force) => 64 | { 65 | var candidate = dynamicPos + velocity + force; 66 | var curFw = staticSource.DirTo(in candidate, out var dist); 67 | var degrees = fun.angle.BetweenVectorsUnSignedInDegrees(in iniFw, in curFw); 68 | var x = degrees / _cfg.MaxDegrees; 69 | //var y = bezier(x, 0.70, 0.00, 1.00, 0.00, 0.80, 1.00, 0.97, 1.00); 70 | //var y = bezier(x, 0.80, 0.00, 1.00, 0.00, 0.90, 1.00, 1.00, 1.00); 71 | var y = pow(x, 16).Clamp01(); 72 | if (y < 0.001) 73 | { 74 | return false; 75 | } 76 | velocity = velocity * (1f - y); 77 | if (degrees > _cfg.MaxDegrees) 78 | { 79 | dynamicPos = staticSource + iniFw.RotateTowards(curFw, _cfg.MaxDegrees) * dist; 80 | } 81 | 82 | return true; 83 | }); 84 | 85 | // Debug.DrawLine(_cfg.Bone.position, staticTarget, Color.black, 0, false); 86 | // Debug.DrawLine(_cfg.Bone.position, dynamicTarget, Color.magenta, 0, false); 87 | 88 | var fw = (dynamicTarget - staticSource).ToUnit(out var length); 89 | var rotation = 90 | Quaternion.LookRotation(fw, _relIniUp.AsWorldDir(_cfg.Bone.parent)); 91 | 92 | var xx = (length / _cfg.RelTargetAt).FromRangeTo01(0, 2); 93 | 94 | var yy = bezier(xx, 0.00, -1.00, 0.50, -1.00, 0.50, 1.00, 1.00, 1.00); 95 | 96 | var pos = staticSource; 97 | 98 | var span = yy < 0 ? _cfg.MaxSqueeze : _cfg.MaxStretch; 99 | if (abs(span) > 0.0001) 100 | { 101 | pos = pos + iniFw * (yy * (float)span); 102 | } 103 | return ( 104 | position: pos, 105 | rotation: rotation 106 | ); 107 | } 108 | } 109 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Main/BaseMainScript.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | using Extensions; 5 | using Unianio; 6 | using UnityEngine; 7 | using UnityFunctions; 8 | 9 | namespace Main 10 | { 11 | public abstract class BaseMainScript : MonoBehaviour 12 | { 13 | protected Transform _a, _b,_c; 14 | protected Mesh _mesh; 15 | private readonly bool[] _hasPrev = new bool[10]; 16 | 17 | protected readonly IDictionary ChangeNames = new Dictionary(StringComparer.InvariantCultureIgnoreCase); 18 | 19 | protected GameObject CreateTriangle(double pointSize) 20 | { 21 | var dt = new DtTrianglePlane(); 22 | var tr = fun.meshes.CreateTwoSidedTrianglePlane(dt).SetStandardShaderTransparentColor(0,0,1,0.5); 23 | 24 | _a = fun.meshes.CreateSphere(new DtSphere {radius = pointSize, name = "Tri_ver_a"}).SetStandardShaderTransparentColor(0,1,0,0.9).transform; 25 | _b = fun.meshes.CreateSphere(new DtSphere {radius = pointSize, name = "Tri_ver_b"}).SetStandardShaderTransparentColor(0,1,0,0.9).transform; 26 | _c = fun.meshes.CreateSphere(new DtSphere {radius = pointSize, name = "Tri_ver_c"}).SetStandardShaderTransparentColor(0,1,0,0.9).transform; 27 | _mesh = dt.mesh; 28 | 29 | _a.position = _mesh.vertices[0]; 30 | _b.position = _mesh.vertices[1]; 31 | _c.position = _mesh.vertices[2]; 32 | 33 | return tr; 34 | } 35 | 36 | protected GameObject CreateTriangle(double pointSize, out Transform a, out Transform b, out Transform c, out Mesh mesh) 37 | { 38 | var dt = new DtTrianglePlane(); 39 | var tr = fun.meshes.CreateTwoSidedTrianglePlane(dt).SetStandardShaderTransparentColor(0,0,1,0.5); 40 | 41 | a = fun.meshes.CreateSphere(new DtSphere {radius = pointSize, name = "Tri_ver_a"}).SetStandardShaderTransparentColor(0,1,0,0.9).transform; 42 | b = fun.meshes.CreateSphere(new DtSphere {radius = pointSize, name = "Tri_ver_b"}).SetStandardShaderTransparentColor(0,1,0,0.9).transform; 43 | c = fun.meshes.CreateSphere(new DtSphere {radius = pointSize, name = "Tri_ver_c"}).SetStandardShaderTransparentColor(0,1,0,0.9).transform; 44 | mesh = dt.mesh; 45 | 46 | a.position = mesh.vertices[0]; 47 | b.position = mesh.vertices[1]; 48 | c.position = mesh.vertices[2]; 49 | 50 | return tr; 51 | } 52 | 53 | protected void SetTriangle(out Vector3 a, out Vector3 b, out Vector3 c) 54 | { 55 | a = _a.position; 56 | b = _b.position; 57 | c = _c.position; 58 | 59 | _mesh.vertices = new [] {a,b,c}; 60 | } 61 | protected void SetTriangle(out Vector3 a, out Vector3 b, out Vector3 c, out Vector3 planeNormal) 62 | { 63 | SetTriangle(out a, out b, out c); 64 | fun.point.GetNormal(in a, in b, in c, out planeNormal); 65 | } 66 | 67 | protected void SetTriangle(Transform t1, Transform t2, Transform t3, Mesh m, out Vector3 a, out Vector3 b, out Vector3 c) 68 | { 69 | a = t1.position; 70 | b = t2.position; 71 | c = t3.position; 72 | 73 | m.vertices = new [] {a,b,c}; 74 | } 75 | protected void SetTriangle(Transform t1, Transform t2, Transform t3, Mesh m, out Vector3 a, out Vector3 b, out Vector3 c, out Vector3 planeNormal) 76 | { 77 | SetTriangle(t1, t2, t3, m,out a, out b, out c); 78 | planeNormal = fun.point.GetNormal(a, b, c); 79 | } 80 | protected static void SetColor(bool hasIntersection, Color ifTrue, Color ifFalse, params Transform[] ts) 81 | { 82 | foreach (var t in ts) 83 | { 84 | t.gameObject.SetStandardShaderTransparentColor(hasIntersection ? ifTrue : ifFalse); 85 | } 86 | } 87 | 88 | protected void SetColorOnChanged(bool hasCondition, Color ifTrue, Color ifFalse, params Transform[] ts) 89 | { 90 | if(ts.Length == 0) throw new ArgumentException("Please provide 1 or more Transform parameters for SetColorOnChanged method"); 91 | SetColorOnChanged("hc"+ts[0].GetHashCode(), hasCondition, ifTrue, ifFalse, ts); 92 | } 93 | protected void SetColorOnChanged(string changeName, bool hasIntersection, Color ifTrue, Color ifFalse, params Transform[] ts) 94 | { 95 | bool val; 96 | var found = ChangeNames.TryGetValue(changeName, out val); 97 | if(found && val == hasIntersection) return;// no change; 98 | ChangeNames[changeName] = hasIntersection; 99 | foreach (var t in ts) 100 | { 101 | t.gameObject.SetStandardShaderTransparentColor(hasIntersection ? ifTrue : ifFalse); 102 | } 103 | } 104 | protected bool IsShiftKeyAndNumberDown(int num) 105 | { 106 | var key = (KeyCode)(48+num); 107 | var hasNext = Input.GetKey(key); 108 | var hasPrev = _hasPrev[num]; 109 | _hasPrev[num] = hasNext; 110 | return !hasPrev && hasNext && (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)); 111 | } 112 | protected static Color rgba(double r, double g, double b, double a) 113 | { 114 | return new Color((float)r,(float)g,(float)b,(float)a); 115 | } 116 | 117 | protected static Vector3 V3(double x, double y, double z) 118 | { 119 | return new Vector3((float)x,(float)y,(float)z); 120 | } 121 | 122 | } 123 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Extensions/QuaternionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Unianio; 3 | using UnityEngine; 4 | using static Unianio.fun; 5 | 6 | namespace Extensions 7 | { 8 | internal static class QuaternionExtensions 9 | { 10 | internal static Quaternion RelativeTo(in this Quaternion a, in Quaternion b) 11 | { 12 | return Quaternion.Inverse(a) * b; 13 | } 14 | internal static Quaternion LocalToWorld(in this Quaternion local, in Quaternion parentWorld) 15 | { 16 | return Quaternion.Inverse(local) * parentWorld; 17 | } 18 | internal static string s(in this Quaternion q) 19 | { 20 | return q.x.s() + "," + q.y.s() + "," + q.z.s() + "," + q.w.s(); 21 | } 22 | internal static Vector4 ToV4(in this Quaternion q) 23 | { 24 | return new Vector4(q.x, q.y, q.z, q.w); 25 | } 26 | internal static Quaternion ToQt(in this Vector4 v) 27 | { 28 | return new Quaternion(v.x, v.y, v.z, v.w); 29 | } 30 | internal static Quaternion AsHorizontal(in this Quaternion q) 31 | { 32 | var fwDir = q * Vector3.forward; 33 | var upDir = q * Vector3.up; 34 | var isUpUp = fun.vector.PointSameDirection(in upDir, in v3.up); 35 | upDir = isUpUp ? Vector3.up : Vector3.down; 36 | return Quaternion.LookRotation(fwDir.ToHorzUnit(), upDir); 37 | } 38 | internal static Quaternion AsLocalRot(in this Quaternion worldRotation, Transform parent) 39 | { 40 | return parent == null ? worldRotation : Quaternion.Inverse(parent.rotation) * worldRotation; 41 | } 42 | internal static Quaternion AsLocalRot(in this Quaternion worldRotation, in Quaternion parentWorld) 43 | { 44 | return Quaternion.Inverse(parentWorld) * worldRotation; 45 | } 46 | internal static Quaternion AsWorldRot(in this Quaternion localRotation, Transform parent) 47 | { 48 | return parent == null ? localRotation : parent.rotation * localRotation; 49 | } 50 | internal static Quaternion AsWorldRot(in this Quaternion localRotation, in Quaternion parentWorld) 51 | { 52 | return parentWorld * localRotation; 53 | } 54 | internal static Quaternion RotateTowards(in this Quaternion from, in Vector3 toFw, in Vector3 toUp, double maxDegreesDelta) 55 | { 56 | return from.RotateTowards(lookAt(toFw, toUp), maxDegreesDelta); 57 | } 58 | internal static Quaternion RotateTowards(in this Quaternion from, in Quaternion to, double maxDegreesDelta) 59 | { 60 | var angleDegrees = angle.Between(in from, in to); 61 | if (Math.Abs(angleDegrees) < 0.00001 || maxDegreesDelta >= 180) 62 | return to; 63 | var t = (float)Math.Min(1f, maxDegreesDelta / angleDegrees); 64 | return Quaternion.SlerpUnclamped(from, to, t); 65 | } 66 | internal static void RotateTowards(in this Quaternion from, in Quaternion to, double maxDegreesDelta, out Quaternion output) 67 | { 68 | var angleDegrees = angle.Between(in from, in to); 69 | if (Math.Abs(angleDegrees) < 0.00001 || maxDegreesDelta >= 180) 70 | { 71 | output = to; 72 | return; 73 | } 74 | var t = (float)Math.Min(1f, maxDegreesDelta / angleDegrees); 75 | output = Quaternion.SlerpUnclamped(from, to, t); 76 | } 77 | 78 | const double TwiseRadiansToDegrees = 2.0 * 57.2957801818848; 79 | internal static float DegreesTo(in this Quaternion from, in Quaternion to) 80 | { 81 | return (float)((double)Math.Acos(Math.Min(Math.Abs(dot(in from, in to)), 1f)) * TwiseRadiansToDegrees); 82 | } 83 | internal static float RadiansTo(in this Quaternion from, in Quaternion to) 84 | { 85 | return (float)((double)Math.Acos(Math.Min(Math.Abs(dot(in from, in to)), 1f)) * 2); 86 | } 87 | internal static bool IsEqual(in this Quaternion a, in Quaternion b) 88 | { 89 | return 90 | ((double)a.x).IsEqual((double)b.x) && 91 | ((double)a.y).IsEqual((double)b.y) && 92 | ((double)a.z).IsEqual((double)b.z) && 93 | ((double)a.w).IsEqual((double)b.w); 94 | } 95 | internal static bool IsEqual(in this Quaternion a, in Quaternion b, double delta) 96 | { 97 | return 98 | ((double)a.x).IsEqual((double)b.x, delta) && 99 | ((double)a.y).IsEqual((double)b.y, delta) && 100 | ((double)a.z).IsEqual((double)b.z, delta) && 101 | ((double)a.w).IsEqual((double)b.w, delta); 102 | } 103 | internal static bool Equals(in this Quaternion a, in Quaternion b) 104 | { 105 | if (a.x.Equals(b.x) && a.y.Equals(b.y) && a.z.Equals(b.z)) 106 | return a.w.Equals(b.w); 107 | return false; 108 | } 109 | internal static void Normalize(this Quaternion q) 110 | { 111 | var num2 = (((q.x * q.x) + (q.y * q.y)) + (q.z * q.z)) + (q.w * q.w); 112 | var num = 1f / ((float)Math.Sqrt(num2)); 113 | q.x *= num; 114 | q.y *= num; 115 | q.z *= num; 116 | q.w *= num; 117 | } 118 | /* 119 | roll = atan2(2*gety*w - 2*x*z, 1 - 2*gety*gety - 2*z*z) 120 | pitch = atan2(2*x*w - 2*gety*z, 1 - 2*x*x - 2*z*z) 121 | yaw = asin(2*x*gety + 2*z*w) 122 | * 123 | roll = Mathf.Atan2(2*gety*w - 2*x*z, 1 - 2*gety*gety - 2*z*z); 124 | pitch = Mathf.Atan2(2*x*w - 2*gety*z, 1 - 2*x*x - 2*z*z); 125 | yaw = Mathf.Asin(2*x*gety + 2*z*w); 126 | */ 127 | 128 | internal static float GetYaw(in this Quaternion q) 129 | { 130 | return q.eulerAngles.y; 131 | } 132 | internal static float GetPitch(in this Quaternion q) 133 | { 134 | return q.eulerAngles.x; 135 | } 136 | internal static float GetRoll(in this Quaternion q) 137 | { 138 | return q.eulerAngles.z; 139 | } 140 | internal static void GetYawPitchRoll(in this Quaternion q, out float yaw, out float pitch, out float roll) 141 | { 142 | yaw = q.eulerAngles.y; 143 | pitch = q.eulerAngles.x; 144 | roll = q.eulerAngles.z; 145 | } 146 | } 147 | 148 | } -------------------------------------------------------------------------------- /UnityFunctions/Assets/Scripts/Extensions/DoubleExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Text; 4 | using System.Threading; 5 | 6 | namespace Extensions 7 | { 8 | internal static class DoubleExtensions 9 | { 10 | internal const double Epsilon = 9.99999974737875E-06; 11 | 12 | internal static float Float(this double d) { return (float)d; } 13 | 14 | internal static double FromRangeTo01(this double xOfRange, double xMin, double xMax) 15 | { 16 | var diff = xMax - xMin; 17 | return (Math.Abs(diff) < 0.0000001 ? 1.0 : (xOfRange - xMin) / diff); 18 | } 19 | 20 | internal static double From01ToRange(this double x01, double xMin, double xMax) 21 | { 22 | return ((xMax - xMin) * x01 + xMin); 23 | } 24 | 25 | internal static double From01To(this double x, double yForX0, double yForX1) 26 | { 27 | return (x * (yForX1 - yForX0) + yForX0); 28 | } 29 | internal static double FromMin11To01(this double x) 30 | { 31 | return (x) * 0.5f + 0.5f; 32 | } 33 | internal static double From01ToMin11(this double x) 34 | { 35 | return 2 * x - 1f; 36 | } 37 | internal static double IfConditionTransform(this double x, Func condition, Func transform) 38 | { 39 | if (condition(x)) 40 | { 41 | return transform(x); 42 | } 43 | return x; 44 | } 45 | internal static double Round(this double n, int digits) 46 | { 47 | return Math.Round(n, digits); 48 | } 49 | internal static bool IsZero(this double n) 50 | { 51 | return n.IsZero(Epsilon); 52 | } 53 | internal static bool IsZero(this double n, double epsilon) 54 | { 55 | return n < epsilon && n > -epsilon; 56 | } 57 | internal static float GoTowards(this double from, double to, double step) 58 | { 59 | var diff = to - from; 60 | if (diff.Abs() <= step) return (float)to; 61 | var sign = diff < 0 ? -1 : 1; 62 | return (float)(from + step * sign); 63 | } 64 | internal static bool IsBetween(this double n, double from, double to) 65 | { 66 | return n >= from && n <= to; 67 | } 68 | internal static bool IsEqual(this double n, double m) 69 | { 70 | return n.IsEqual(m, Epsilon); 71 | } 72 | internal static bool IsEqual(this double n, double m, double epsilon) 73 | { 74 | return Math.Abs(n - m) < epsilon; 75 | } 76 | internal static float Project(this double n, Func fn) 77 | { 78 | if (fn == null) return (float)n; // no function is considered linear identity function 79 | return (float)fn(n); 80 | } 81 | 82 | internal static double Abs(this double n) 83 | { 84 | return n >= 0 ? n : n * -1; 85 | } 86 | internal static double NoMoreThan(this double a, double b) { return a > b ? b : a; } 87 | internal static double NoLessThan(this double a, double b) { return a < b ? b : a; } 88 | internal static double Clamp(this double value, double min, double max) 89 | { 90 | if (value < min) 91 | { 92 | return min; 93 | } 94 | if (value > max) 95 | { 96 | return max; 97 | } 98 | return value; 99 | } 100 | internal static double Clamp01(this double value) 101 | { 102 | if (value < 0) 103 | { 104 | return 0.0; 105 | } 106 | if (value > 1) 107 | { 108 | return 1.0; 109 | } 110 | return value; 111 | } 112 | internal static double ClampMin11(this double value) 113 | { 114 | if (value < -1) 115 | { 116 | return -1.0; 117 | } 118 | if (value > 1) 119 | { 120 | return 1.0; 121 | } 122 | return value; 123 | } 124 | 125 | internal static float OfM11Range(this double progress, double min, double max) 126 | { 127 | progress = 0.5 * progress + 0.5; 128 | return (float)(min + progress * (max - min)); 129 | } 130 | internal static string s(this double input) 131 | { 132 | string str = input.ToString(CultureInfo.InvariantCulture); 133 | 134 | // if string representation was collapsed from scientific notation, just return it: 135 | if (str.IndexOf("E", StringComparison.OrdinalIgnoreCase) < 0) return str; 136 | 137 | bool negativeNumber = false; 138 | 139 | if (str[0] == '-') 140 | { 141 | str = str.Remove(0, 1); 142 | negativeNumber = true; 143 | } 144 | 145 | string sep = Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator; 146 | char decSeparator = sep.ToCharArray()[0]; 147 | 148 | string[] exponentParts = str.Split('E'); 149 | string[] decimalParts = exponentParts[0].Split(decSeparator); 150 | 151 | // fix missing decimal point: 152 | if (decimalParts.Length == 1) decimalParts = new string[] { exponentParts[0], "0" }; 153 | 154 | int exponentValue = int.Parse(exponentParts[1]); 155 | 156 | string newNumber = decimalParts[0] + decimalParts[1]; 157 | 158 | string result; 159 | 160 | if (exponentValue > 0) 161 | { 162 | result = 163 | newNumber + 164 | GetZeros(exponentValue - decimalParts[1].Length); 165 | } 166 | else // negative exponent 167 | { 168 | result = 169 | "0" + 170 | decSeparator + 171 | GetZeros(exponentValue + decimalParts[0].Length) + 172 | newNumber; 173 | 174 | result = result.TrimEnd('0'); 175 | } 176 | 177 | if (negativeNumber) 178 | result = "-" + result; 179 | 180 | return result; 181 | } 182 | 183 | private static string GetZeros(int zeroCount) 184 | { 185 | if (zeroCount < 0) 186 | zeroCount = Math.Abs(zeroCount); 187 | 188 | var sb = new StringBuilder(); 189 | 190 | for (int i = 0; i < zeroCount; i++) sb.Append("0"); 191 | 192 | return sb.ToString(); 193 | } 194 | } 195 | 196 | } --------------------------------------------------------------------------------