From 406307a432e08b3d251ec45ca1d4b3f2a841f7ce Mon Sep 17 00:00:00 2001 From: Alexander Rose <alexander.rose@weirdbyte.de> Date: Sat, 30 Oct 2021 16:48:47 -0700 Subject: [PATCH] add radiusScale param to orientation measurement --- src/mol-math/geometry/primitives/axes3d.ts | 11 +++++++++-- src/mol-repr/shape/loci/orientation.ts | 13 +++++++------ src/mol-repr/shape/loci/plane.ts | 6 ++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/mol-math/geometry/primitives/axes3d.ts b/src/mol-math/geometry/primitives/axes3d.ts index bb70f70ef..5db8ae4f5 100644 --- a/src/mol-math/geometry/primitives/axes3d.ts +++ b/src/mol-math/geometry/primitives/axes3d.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -48,7 +48,7 @@ namespace Axes3D { return out; } - const tmpTransformMat3 = Mat3.zero(); + const tmpTransformMat3 = Mat3(); /** Transform axes with a Mat4 */ export function transform(out: Axes3D, a: Axes3D, m: Mat4): Axes3D { Vec3.transformMat4(out.origin, a.origin, m); @@ -58,6 +58,13 @@ namespace Axes3D { Vec3.transformMat3(out.dirC, a.dirC, n); return out; } + + export function scale(out: Axes3D, a: Axes3D, scale: number): Axes3D { + Vec3.scale(out.dirA, a.dirA, scale); + Vec3.scale(out.dirB, a.dirB, scale); + Vec3.scale(out.dirC, a.dirC, scale); + return out; + } } export { Axes3D }; \ No newline at end of file diff --git a/src/mol-repr/shape/loci/orientation.ts b/src/mol-repr/shape/loci/orientation.ts index acccf4184..451aff38e 100644 --- a/src/mol-repr/shape/loci/orientation.ts +++ b/src/mol-repr/shape/loci/orientation.ts @@ -27,7 +27,8 @@ export interface OrientationData { const SharedParams = { color: PD.Color(ColorNames.orange), - scale: PD.Numeric(2, { min: 0.1, max: 10, step: 0.1 }) + scaleFactor: PD.Numeric(1, { min: 0.1, max: 10, step: 0.1 }), + radiusScale: PD.Numeric(2, { min: 0.1, max: 10, step: 0.1 }) }; const AxesParams = { @@ -59,8 +60,6 @@ export const OrientationParams = { ...BoxParams, ...EllipsoidParams, visuals: PD.MultiSelect(['box'], PD.objectToOptions(OrientationVisuals)), - color: PD.Color(ColorNames.orange), - scale: PD.Numeric(2, { min: 0.1, max: 5, step: 0.1 }) }; export type OrientationParams = typeof OrientationParams export type OrientationProps = PD.Values<OrientationParams> @@ -75,9 +74,10 @@ function getAxesName(locis: StructureElement.Loci[]) { function buildAxesMesh(data: OrientationData, props: OrientationProps, mesh?: Mesh): Mesh { const state = MeshBuilder.createState(256, 128, mesh); const principalAxes = StructureElement.Loci.getPrincipalAxesMany(data.locis); + Axes3D.scale(principalAxes.momentsAxes, principalAxes.momentsAxes, props.scaleFactor); state.currentGroup = 0; - addAxes(state, principalAxes.momentsAxes, props.scale, 2, 20); + addAxes(state, principalAxes.momentsAxes, props.radiusScale, 2, 20); return MeshBuilder.getMesh(state); } @@ -97,9 +97,10 @@ function getBoxName(locis: StructureElement.Loci[]) { function buildBoxMesh(data: OrientationData, props: OrientationProps, mesh?: Mesh): Mesh { const state = MeshBuilder.createState(256, 128, mesh); const principalAxes = StructureElement.Loci.getPrincipalAxesMany(data.locis); + Axes3D.scale(principalAxes.boxAxes, principalAxes.boxAxes, props.scaleFactor); state.currentGroup = 0; - addOrientedBox(state, principalAxes.boxAxes, props.scale, 2, 20); + addOrientedBox(state, principalAxes.boxAxes, props.radiusScale, 2, 20); return MeshBuilder.getMesh(state); } @@ -123,7 +124,7 @@ function buildEllipsoidMesh(data: OrientationData, props: OrientationProps, mesh const axes = principalAxes.boxAxes; const { origin, dirA, dirB } = axes; const size = Axes3D.size(Vec3(), axes); - Vec3.scale(size, size, 0.5); + Vec3.scale(size, size, 0.5 * props.scaleFactor); const radiusScale = Vec3.create(size[2], size[1], size[0]); state.currentGroup = 0; diff --git a/src/mol-repr/shape/loci/plane.ts b/src/mol-repr/shape/loci/plane.ts index e33213648..719f3ae19 100644 --- a/src/mol-repr/shape/loci/plane.ts +++ b/src/mol-repr/shape/loci/plane.ts @@ -26,7 +26,7 @@ export interface PlaneData { const _PlaneParams = { ...Mesh.Params, color: PD.Color(ColorNames.orange), - scale: PD.Numeric(1, { min: 0.1, max: 10, step: 0.1 }) + scaleFactor: PD.Numeric(1, { min: 0.1, max: 10, step: 0.1 }), }; type _PlaneParams = typeof _PlaneParams @@ -37,8 +37,6 @@ const PlaneVisuals = { export const PlaneParams = { ..._PlaneParams, visuals: PD.MultiSelect(['plane'], PD.objectToOptions(PlaneVisuals)), - color: PD.Color(ColorNames.orange), - scale: PD.Numeric(1, { min: 0.1, max: 5, step: 0.1 }) }; export type PlaneParams = typeof PlaneParams export type PlaneProps = PD.Values<PlaneParams> @@ -61,7 +59,7 @@ function buildPlaneMesh(data: PlaneData, props: PlaneProps, mesh?: Mesh): Mesh { Vec3.add(tmpV, axes.origin, axes.dirC); Mat4.targetTo(tmpMat, tmpV, axes.origin, axes.dirB); Mat4.scale(tmpMat, tmpMat, Axes3D.size(tmpV, axes)); - Mat4.scaleUniformly(tmpMat, tmpMat, props.scale); + Mat4.scaleUniformly(tmpMat, tmpMat, props.scaleFactor); Mat4.setTranslation(tmpMat, axes.origin); state.currentGroup = 0; -- GitLab