From 58791249977f4605ad4005c2519947d31ffd9499 Mon Sep 17 00:00:00 2001 From: dirckvdende <128695295+dirckvdende@users.noreply.github.com> Date: Wed, 21 Jan 2026 09:43:29 +0100 Subject: [PATCH 1/4] #141 - Added directional relative position and velocity to useObjectCompareStats --- src/composables/useObjectCompareStats.ts | 55 +++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/src/composables/useObjectCompareStats.ts b/src/composables/useObjectCompareStats.ts index 68b3305..9094419 100644 --- a/src/composables/useObjectCompareStats.ts +++ b/src/composables/useObjectCompareStats.ts @@ -4,6 +4,9 @@ import type { StyledGravityObject } from "@/util/sim/object"; import { computed, toValue, type ComputedRef } from "vue"; import Vector3 from "@/util/linalg/Vector3"; import { DISTANCE_SMOOTHING, GRAV_CONSTANT } from "@/util/sim/constants"; +import { forceOnObject } from "@/util/sim/odeConvert"; +import Matrix from "@/util/linalg/Matrix"; +import Vector from "@/util/linalg/Vector"; /** Return value of the object compare stats composable */ export type ObjectCompareStatsReturn = { @@ -17,6 +20,16 @@ export type ObjectCompareStatsReturn = { relativePosition: ComputedRef /** Relative velocity to compare object */ relativeVelocity: ComputedRef + /** + * Directional position relative to compare object (directions are given by + * velocity and acting force of original object) + */ + directionalRelativePosition: ComputedRef + /** + * Directional velocity relative to compare object (directions are given by + * velocity and acting force of original object) + */ + directionalRelativeVelocity: ComputedRef /** Relative escape velocity between the two objects */ escapeVelocity: ComputedRef /** @@ -82,6 +95,45 @@ StyledGravityObject[] | null | undefined>): ObjectCompareStatsReturn { object.position.subtract(otherObject.position)) const relativeVelocity = definedComputed((object, otherObject) => object.velocity.subtract(otherObject.velocity)) + + const force = definedComputed((object, _, allObjects) => + forceOnObject(object, allObjects)) + const directionalBasis = definedComputed((object) => { + if (!force.value) + return undefined + const velocity = new Vector(object.velocity.x, object.velocity.y, + object.velocity.z) + const forceVector = new Vector(force.value.x, force.value.y, + force.value.z) + const onb = Vector.orthonormalBasis(velocity, forceVector, + new Vector(1, 0, 0), new Vector(0, 1, 0), new Vector(0, 0, 1)) + if (onb.length != 3) + return undefined + return onb as [Vector, Vector, Vector] + }) + const directionalMatrix = computed(() => { + const basis = directionalBasis.value + if (!basis) + return undefined + return new Matrix(...basis).transpose().inverse() + }) + const directionalRelativePosition = computed(() => { + if (!relativePosition.value || !directionalMatrix.value) + return undefined + const v = directionalMatrix.value.multiply(new Vector( + relativePosition.value.x, relativePosition.value.y, + relativePosition.value.z)) + return new Vector3(v.get(0), v.get(1), v.get(2)) + }) + const directionalRelativeVelocity = computed(() => { + if (!relativeVelocity.value || !directionalMatrix.value) + return undefined + const v = directionalMatrix.value.multiply(new Vector( + relativeVelocity.value.x, relativeVelocity.value.y, + relativeVelocity.value.z)) + return new Vector3(v.get(0), v.get(1), v.get(2)) + }) + const distance = definedComputed((object, otherObject) => object.position.subtract(otherObject.position).length()) const massRatio = definedComputed((object, otherObject) => @@ -142,7 +194,8 @@ StyledGravityObject[] | null | undefined>): ObjectCompareStatsReturn { return { relativePosition, relativeVelocity, distance, massRatio, sizeRatio, escapeVelocity, gravBound, barycenter, eccentricityVector, - semiMajorAxis, orbitalPeriod, + semiMajorAxis, orbitalPeriod, directionalRelativePosition, + directionalRelativeVelocity, } } \ No newline at end of file From c600a1c8466d0e4019435a3296848b6d603cdfd1 Mon Sep 17 00:00:00 2001 From: dirckvdende <128695295+dirckvdende@users.noreply.github.com> Date: Wed, 21 Jan 2026 09:43:48 +0100 Subject: [PATCH 2/4] #141 - Added directional relative position and velocity to object details menu --- src/components/AppMenuObjectDetails.vue | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/AppMenuObjectDetails.vue b/src/components/AppMenuObjectDetails.vue index 49ea5d5..2236d8c 100644 --- a/src/components/AppMenuObjectDetails.vue +++ b/src/components/AppMenuObjectDetails.vue @@ -71,7 +71,7 @@ const { distance, massRatio, sizeRatio, relativePosition, relativeVelocity, escapeVelocity, gravBound, eccentricityVector, semiMajorAxis, - orbitalPeriod, + orbitalPeriod, directionalRelativePosition, directionalRelativeVelocity, } = useObjectCompareStats(focusedObject, compareObject, objects) const graphComponents = [ @@ -87,6 +87,8 @@ useTemplateRef("distance-ref"), useTemplateRef("relative-position-ref"), useTemplateRef("relative-velocity-ref"), + useTemplateRef("directional-relative-position-ref"), + useTemplateRef("directional-relative-velocity-ref"), useTemplateRef("escape-velocity-ref"), useTemplateRef("eccentricity-ref"), useTemplateRef("semi-major-axis-ref"), @@ -190,6 +192,15 @@ ref="relative-velocity-ref" :units="VELOCITY_UNITS" show-length has-graph>Relative velocity + + Direct. rel. pos. + + Direct. rel. vel. + Rel. escape velocity From 3a7b6ab4ee0107835f97709d22e99b05ca8a160b Mon Sep 17 00:00:00 2001 From: dirckvdende <128695295+dirckvdende@users.noreply.github.com> Date: Wed, 21 Jan 2026 09:47:57 +0100 Subject: [PATCH 3/4] #141 - Made directions of directional relative position and velocity dependent on compare object --- src/composables/useObjectCompareStats.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/composables/useObjectCompareStats.ts b/src/composables/useObjectCompareStats.ts index 9094419..9bc6191 100644 --- a/src/composables/useObjectCompareStats.ts +++ b/src/composables/useObjectCompareStats.ts @@ -22,12 +22,12 @@ export type ObjectCompareStatsReturn = { relativeVelocity: ComputedRef /** * Directional position relative to compare object (directions are given by - * velocity and acting force of original object) + * velocity and acting force of compare object) */ directionalRelativePosition: ComputedRef /** * Directional velocity relative to compare object (directions are given by - * velocity and acting force of original object) + * velocity and acting force of compare object) */ directionalRelativeVelocity: ComputedRef /** Relative escape velocity between the two objects */ @@ -98,11 +98,11 @@ StyledGravityObject[] | null | undefined>): ObjectCompareStatsReturn { const force = definedComputed((object, _, allObjects) => forceOnObject(object, allObjects)) - const directionalBasis = definedComputed((object) => { + const directionalBasis = definedComputed((_, otherObject) => { if (!force.value) return undefined - const velocity = new Vector(object.velocity.x, object.velocity.y, - object.velocity.z) + const velocity = new Vector(otherObject.velocity.x, + otherObject.velocity.y, otherObject.velocity.z) const forceVector = new Vector(force.value.x, force.value.y, force.value.z) const onb = Vector.orthonormalBasis(velocity, forceVector, From 4cdc73d4088c0e87a52761acf28478a507c72be0 Mon Sep 17 00:00:00 2001 From: dirckvdende <128695295+dirckvdende@users.noreply.github.com> Date: Wed, 21 Jan 2026 10:03:23 +0100 Subject: [PATCH 4/4] #141 - Fixed directional relative coordinate system not using force on compare object --- src/composables/useObjectCompareStats.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/composables/useObjectCompareStats.ts b/src/composables/useObjectCompareStats.ts index 9bc6191..47e2ff1 100644 --- a/src/composables/useObjectCompareStats.ts +++ b/src/composables/useObjectCompareStats.ts @@ -96,8 +96,8 @@ StyledGravityObject[] | null | undefined>): ObjectCompareStatsReturn { const relativeVelocity = definedComputed((object, otherObject) => object.velocity.subtract(otherObject.velocity)) - const force = definedComputed((object, _, allObjects) => - forceOnObject(object, allObjects)) + const force = definedComputed((_, otherObject, allObjects) => + forceOnObject(otherObject, allObjects)) const directionalBasis = definedComputed((_, otherObject) => { if (!force.value) return undefined