Skip to content
Snippets Groups Projects
Commit 7f76233d authored by Alexander Rose's avatar Alexander Rose
Browse files

added Sphere.fromBox3D

parent f28313fd
No related branches found
No related tags found
No related merge requests found
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
......@@ -9,6 +9,7 @@ import { Vec3, Mat4, EPSILON } from '../../linear-algebra'
import { PositionData } from '../common'
import { OrderedSet } from 'mol-data/int';
import { NumberArray } from 'mol-util/type-helpers';
import { Box3D } from './box3d';
interface Sphere3D { center: Vec3, radius: number }
......@@ -76,6 +77,12 @@ namespace Sphere3D {
return out
}
export function fromBox3D(out: Sphere3D, box: Box3D) {
Vec3.scale(out.center, Vec3.add(out.center, box.max, box.min), 0.5)
out.radius = Vec3.distance(out.center, box.max)
return out
}
export function addSphere(out: Sphere3D, sphere: Sphere3D) {
out.radius = Math.max(out.radius, Vec3.distance(out.center, sphere.center) + sphere.radius)
return out
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment