john_connor

05-16-2017, 04:40 AM

hi there,

library used: glm

lets say we have 3 arbitrary points A, B and C in 3D space, we dont know if and which are laying in a line or even if all of those are (0|0|0). the coords of these points are described in float (or double)

1. question:

whats the approch to calculate the point in 3D space that is the center if a circle which lays on these 3 points, the "circumscribed circle" center ?

in pure math (that is without bothering about floating-point precision etc), i'd:

middleAB = A + AB / 2

normal = cross(AB, AC)

tocenterAB = cross(normal, AB)

first line:

X = middleAB + n * tocenterAB

the same then for AC:

X = middleAC + n * tocenterAC

then intersect both lines. the problem is that the slightest precision loss will make these 2 lines not intersect. how to do it "the right way" ?

2. question:

lets say we have a bunch of points, we want to calculate the center M + radius R of the smallest sphere that contains all of these points:

case 1: 1 point --> R = 0, M = point

case 2: 2 points --> R = AB / 2, M = (A+B) / 2

case 3: 3 points --> ??? see question 1

case 4: 4 points --> ??? :doh:

case N: N points --> reduce to 4 points that are furthest away

the reason for that is that i want to calculate bounding spheres:

struct BoundingSphere {

vec3 Center; /* offset from "local space" */

float Radius = 0.0f;

};

3. question:

would you do that using a (vertex or compute) shader to do that for complex models ?

4. question:

having a model with bones, would you do this calculation at runtime (on the fly instead of once at initialization) ? each frame (possibly not) ? each few (500) milliseconds ? or just precalculate for each "pose" another bounding sphere and interpolate between those ?

i'm looking for a method to check for collision for arbitrary object, these models shouldnt have a "scaling" component so the they only have different translation / rotation component at each bone (if any available). lets say its for a flight simulator kind of game ...

last but not least: can i use glm to do anything of this ?

thanks for your suggestions !

library used: glm

lets say we have 3 arbitrary points A, B and C in 3D space, we dont know if and which are laying in a line or even if all of those are (0|0|0). the coords of these points are described in float (or double)

1. question:

whats the approch to calculate the point in 3D space that is the center if a circle which lays on these 3 points, the "circumscribed circle" center ?

in pure math (that is without bothering about floating-point precision etc), i'd:

middleAB = A + AB / 2

normal = cross(AB, AC)

tocenterAB = cross(normal, AB)

first line:

X = middleAB + n * tocenterAB

the same then for AC:

X = middleAC + n * tocenterAC

then intersect both lines. the problem is that the slightest precision loss will make these 2 lines not intersect. how to do it "the right way" ?

2. question:

lets say we have a bunch of points, we want to calculate the center M + radius R of the smallest sphere that contains all of these points:

case 1: 1 point --> R = 0, M = point

case 2: 2 points --> R = AB / 2, M = (A+B) / 2

case 3: 3 points --> ??? see question 1

case 4: 4 points --> ??? :doh:

case N: N points --> reduce to 4 points that are furthest away

the reason for that is that i want to calculate bounding spheres:

struct BoundingSphere {

vec3 Center; /* offset from "local space" */

float Radius = 0.0f;

};

3. question:

would you do that using a (vertex or compute) shader to do that for complex models ?

4. question:

having a model with bones, would you do this calculation at runtime (on the fly instead of once at initialization) ? each frame (possibly not) ? each few (500) milliseconds ? or just precalculate for each "pose" another bounding sphere and interpolate between those ?

i'm looking for a method to check for collision for arbitrary object, these models shouldnt have a "scaling" component so the they only have different translation / rotation component at each bone (if any available). lets say its for a flight simulator kind of game ...

last but not least: can i use glm to do anything of this ?

thanks for your suggestions !