diff --git a/stim/biomodels/network.h b/stim/biomodels/network.h index 29f4fe5..8cc699e 100644 --- a/stim/biomodels/network.h +++ b/stim/biomodels/network.h @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -37,7 +37,7 @@ class network{ /// Constructor - creates an edge from a list of points by calling the stim::fiber constructor ///@param p is an array of positions in space - edge(std::vector< stim::vec > p) : cylinder(p){} + edge(std::vector< stim::vec3 > p) : cylinder(p){} /// Copy constructor creates an edge from a fiber edge(stim::cylinder f) : cylinder(f) {} @@ -61,20 +61,20 @@ class network{ }; ///Node class that stores the physical position of the node as well as the edges it is connected to (edges that connect to it), As well as any additional data necessary. - class vertex : public stim::vec + class vertex : public stim::vec3 { public: //std::vector edges; //indices of edges connected to this node. std::vector e[2]; //indices of edges going out (e[0]) and coming in (e[1]) - //stim::vec p; //position of this node in physical space. + //stim::vec3 p; //position of this node in physical space. //constructor takes a stim::vec - vertex(stim::vec p) : stim::vec(p){} + vertex(stim::vec3 p) : stim::vec3(p){} /// Output the vertex information as a string std::string str(){ std::stringstream ss; - ss<<"\t(x, y, z) = "<::str(); + ss<<"\t(x, y, z) = "<::str(); if(e[0].size() > 0){ ss<<"\t> "; @@ -129,7 +129,11 @@ public: std::vector< stim::vec > c; //allocate an array of points for the vessel centerline O.getLine(l, c); //get the fiber centerline - edge new_edge = c; //create an edge from the given centerline + std::vector< stim::vec3 > c3(c.size()); + for(size_t j = 0; j < c.size(); j++) + c3[j] = c[j]; + + edge new_edge = c3; //create an edge from the given centerline unsigned int I = new_edge.size(); //calculate the number of points on the centerline //get the first and last vertex IDs for the line @@ -222,7 +226,7 @@ public: float gaussianFunction(float x, float std=25){ return exp(-x/(2*std*std));} // by default std = 25 // stim 3d vector to annpoint of 3 dimensions - void stim2ann(ANNpoint &a, stim::vec b){ + void stim2ann(ANNpoint &a, stim::vec3 b){ a[0] = b[0]; a[1] = b[1]; a[2] = b[2]; @@ -278,10 +282,9 @@ public: ANNdistArray dists = new ANNdist[1]; // near neighbor distances ANNidxArray nnIdx = new ANNidx[1]; // near neighbor indices // allocate near neigh indices - stim::vec p0, p1; - float m0, m1; + stim::vec3 p0, p1; + float m1; float M = 0; //stores the total metric value - float l; //stores the segment length float L = 0; //stores the total network length ANNpoint queryPt = annAllocPt(3); for(unsigned e = 0; e < R.E.size(); e++){ //for each edge in A @@ -292,7 +295,7 @@ public: p1 = R.E[e][p]; //get the next point in the edge stim2ann(queryPt, p1); kdt->annkSearch( queryPt, 1, nnIdx, dists, eps); //find the distance between A and the current network - m1 = 1.0f - gaussianFunction(dists[0], sigma); //calculate the metric value based on the distance + m1 = 1.0f - gaussianFunction((float)dists[0], sigma); //calculate the metric value based on the distance R.E[e].set_mag(m1, p, 1); //set the error for the second point in the segment } diff --git a/stim/math/circle.h b/stim/math/circle.h index 874b292..a395f91 100644 --- a/stim/math/circle.h +++ b/stim/math/circle.h @@ -17,7 +17,7 @@ class circle : plane private: - stim::vec Y; + stim::vec3 Y; CUDA_CALLABLE void init() @@ -48,7 +48,7 @@ public: circle(T size, T z_pos = (T)0) : plane() { init(); - center(stim::vec(0,0,z_pos)); + center(stim::vec3(0,0,z_pos)); scale(size); } @@ -56,7 +56,7 @@ public: ///@param c: x,y,z location of the center. ///@param n: x,y,z direction of the normal. CUDA_CALLABLE - circle(vec c, vec n = vec(0,0,1)) : plane() + circle(vec3 c, vec3 n = vec3(0,0,1)) : plane() { center(c); normal(n); @@ -68,7 +68,7 @@ public: ///@param s: size of the rectangle. ///@param n: x,y,z direction of the normal. CUDA_CALLABLE - circle(vec c, T s, vec n = vec(0,0,1)) : plane() + circle(vec3 c, T s, vec3 n = vec3(0,0,1)) : plane() { init(); center(c); @@ -82,7 +82,7 @@ public: ///@param n: x,y,z direction of the normal. ///@param u: x,y,z direction for the zero vector (from where the rotation starts) CUDA_CALLABLE - circle(vec c, T s, vec n = vec(0,0,1), vec u = vec(1, 0, 0)) : plane() + circle(vec3 c, T s, vec3 n = vec3(0,0,1), vec3 u = vec3(1, 0, 0)) : plane() { init(); setU(u); @@ -103,16 +103,15 @@ public: ///sets the normal for the cirlce ///@param n: x,y,z direction of the normal. CUDA_CALLABLE void - normal(vec n) + normal(vec3 n) { rotate(n, Y); } ///sets the center of the circle. ///@param n: x,y,z location of the center. - CUDA_CALLABLE T - center(vec p) - { + CUDA_CALLABLE void + center(vec3 p){ this->P = p; } @@ -127,17 +126,17 @@ public: } ///get the world space value given the planar coordinates a, b in [0, 1] - CUDA_CALLABLE stim::vec p(T a, T b) + CUDA_CALLABLE stim::vec3 p(T a, T b) { - stim::vec result; + stim::vec3 result; - vec A = this->P - this->U * (T)0.5 - Y * (T)0.5; + vec3 A = this->P - this->U * (T)0.5 - Y * (T)0.5; result = A + this->U * a + Y * b; return result; } ///parenthesis operator returns the world space given rectangular coordinates a and b in [0 1] - CUDA_CALLABLE stim::vec operator()(T a, T b) + CUDA_CALLABLE stim::vec3 operator()(T a, T b) { return p(a,b); } @@ -145,11 +144,11 @@ public: ///returns a vector with the points on the initialized circle. ///connecting the points results in a circle. ///@param n: integer for the number of points representing the circle. - std::vector > + std::vector > getPoints(int n) { - std::vector > result; - stim::vec point; + std::vector > result; + stim::vec3 point; T x,y; float step = 360.0/(float) n; for(float j = 0; j <= 360.0; j += step) @@ -164,7 +163,7 @@ public: ///returns a vector with the points on the initialized circle. ///connecting the points results in a circle. ///@param n: integer for the number of points representing the circle. - stim::vec + stim::vec3 p(T theta) { T x,y; diff --git a/stim/math/matrix.h b/stim/math/matrix.h index b9bebb6..5d749cf 100644 --- a/stim/math/matrix.h +++ b/stim/math/matrix.h @@ -5,6 +5,7 @@ #include #include #include +#include #include namespace stim{ @@ -54,7 +55,7 @@ struct matrix vec operator*(vec rhs){ unsigned int N = rhs.size(); - vec result; + vec3Y> result; result.resize(N); for(int r=0; r -#include +#include #include #include @@ -22,17 +22,17 @@ template class plane { protected: - stim::vec P; - stim::vec N; - stim::vec U; + stim::vec3 P; + stim::vec3 N; + stim::vec3 U; ///Initializes the plane with standard coordinates. /// CUDA_CALLABLE void init() { - P = stim::vec(0, 0, 0); - N = stim::vec(0, 0, 1); - U = stim::vec(1, 0, 0); + P = stim::vec3(0, 0, 0); + N = stim::vec3(0, 0, 1); + U = stim::vec3(1, 0, 0); } public: @@ -42,7 +42,7 @@ class plane init(); } - CUDA_CALLABLE plane(vec n, vec p = vec(0, 0, 0)) + CUDA_CALLABLE plane(vec3 n, vec3 p = vec3(0, 0, 0)) { init(); P = p; @@ -56,11 +56,11 @@ class plane } //create a plane from three points (a triangle) - CUDA_CALLABLE plane(vec a, vec b, vec c) + CUDA_CALLABLE plane(vec3 a, vec3 b, vec3 c) { init(); P = c; - stim::vec n = (c - a).cross(b - a); + stim::vec3 n = (c - a).cross(b - a); try { if(n.len() != 0) @@ -84,17 +84,17 @@ class plane } - CUDA_CALLABLE vec n() + CUDA_CALLABLE vec3 n() { return N; } - CUDA_CALLABLE vec p() + CUDA_CALLABLE vec3 p() { return P; } - CUDA_CALLABLE vec u() + CUDA_CALLABLE vec3 u() { return U; } @@ -107,7 +107,7 @@ class plane } //determines how a vector v intersects the plane (1 = intersects front, 0 = within plane, -1 = intersects back) - CUDA_CALLABLE int face(vec v){ + CUDA_CALLABLE int face(vec3 v){ T dprod = v.dot(N); //get the dot product between v and N @@ -121,46 +121,46 @@ class plane } //determine on which side of the plane a point lies (1 = front, 0 = on the plane, -1 = bac k) - CUDA_CALLABLE int side(vec p){ + CUDA_CALLABLE int side(vec3 p){ - vec v = p - P; //get the vector from P to the query point p + vec3 v = p - P; //get the vector from P to the query point p return face(v); } //compute the component of v that is perpendicular to the plane - CUDA_CALLABLE vec perpendicular(vec v){ + CUDA_CALLABLE vec3 perpendicular(vec3 v){ return N * v.dot(N); } //compute the projection of v in the plane - CUDA_CALLABLE vec parallel(vec v){ + CUDA_CALLABLE vec3 parallel(vec3 v){ return v - perpendicular(v); } - CUDA_CALLABLE void setU(vec v) + CUDA_CALLABLE void setU(vec3 v) { U = (parallel(v.norm())).norm(); } - CUDA_CALLABLE void decompose(vec v, vec& para, vec& perp){ + CUDA_CALLABLE void decompose(vec3 v, vec3& para, vec3& perp){ perp = N * v.dot(N); para = v - perp; } //get both the parallel and perpendicular components of a vector v w.r.t. the plane - CUDA_CALLABLE void project(vec v, vec &v_par, vec &v_perp){ + CUDA_CALLABLE void project(vec3 v, vec3 &v_par, vec3 &v_perp){ v_perp = v.dot(N); v_par = v - v_perp; } //compute the reflection of v off of the plane - CUDA_CALLABLE vec reflect(vec v){ + CUDA_CALLABLE vec3 reflect(vec3 v){ //compute the reflection using N_prime as the plane normal - vec par = parallel(v); - vec r = (-v) + par * 2; + vec3 par = parallel(v); + vec3 r = (-v) + par * 2; return r; } @@ -184,7 +184,7 @@ class plane } - CUDA_CALLABLE void rotate(vec n) + CUDA_CALLABLE void rotate(vec3 n) { quaternion q; q.CreateRotation(N, n); @@ -194,7 +194,7 @@ class plane } - CUDA_CALLABLE void rotate(vec n, vec &Y) + CUDA_CALLABLE void rotate(vec3 n, vec3 &Y) { quaternion q; q.CreateRotation(N, n); @@ -205,7 +205,7 @@ class plane } - CUDA_CALLABLE void rotate(vec n, vec &X, vec &Y) + CUDA_CALLABLE void rotate(vec3 n, vec3 &X, vec3 &Y) { quaternion q; q.CreateRotation(N, n); diff --git a/stim/math/vec3.h b/stim/math/vec3.h index 0fd4dc0..892a370 100644 --- a/stim/math/vec3.h +++ b/stim/math/vec3.h @@ -217,12 +217,12 @@ public: std::string str() const{ std::stringstream ss; - size_t N = size(); + const size_t N = 3; ss<<"["; for(size_t i=0; i return *this; } + /// Cast to a vec3 + operator vec3(){ + vec3 r; + size_t N = std::min(size(), 3); + for(size_t i = 0; i < N; i++) + r[i] = at(i); + return r; + } + /// Casting and assignment template vec & operator=(vec rhs){ diff --git a/stim/visualization/aaboundingbox.h b/stim/visualization/aaboundingbox.h index a0f54cd..c4afbac 100644 --- a/stim/visualization/aaboundingbox.h +++ b/stim/visualization/aaboundingbox.h @@ -10,8 +10,8 @@ class aaboundingbox{ public: bool set; //has the bounding box been set to include any points? - stim::vec A; //minimum point in the bounding box - stim::vec B; //maximum point in the bounding box + stim::vec3 A; //minimum point in the bounding box + stim::vec3 B; //maximum point in the bounding box aaboundingbox(){ //constructor generates an empty bounding box set = false; @@ -21,7 +21,7 @@ public: /// Test if a point is inside of the bounding box and returns true if it is. /// @param p is the point to be tested - bool test(stim::vec p){ + bool test(stim::vec3 p){ for(unsigned d = 0; d < p.size(); p++){ //for each dimension if(p[d] < A[d]) return false; //if the point is less than the minimum bound, return false @@ -33,7 +33,7 @@ public: /// Expand the bounding box to include the specified point. /// @param p is the point to be included - void expand(stim::vec p){ + void expand(stim::vec3 p){ if(!set){ //if the bounding box is empty, fill it with the current point A = B = p; @@ -47,12 +47,12 @@ public: } /// Return the center point of the bounding box as a stim::vec - stim::vec center(){ + stim::vec3 center(){ return (B + A) * 0.5; } /// Return the size of the bounding box as a stim::vec - stim::vec size(){ + stim::vec3 size(){ return (B - A); } diff --git a/stim/visualization/camera.h b/stim/visualization/camera.h index d451c88..4abd4b0 100644 --- a/stim/visualization/camera.h +++ b/stim/visualization/camera.h @@ -11,32 +11,32 @@ namespace stim{ class camera { - vec d; //direction that the camera is pointing - vec p; //position of the camera - vec up; //"up" direction + vec3 d; //direction that the camera is pointing + vec3 p; //position of the camera + vec3 up; //"up" direction float focus; //focal length of the camera float fov; //private function makes sure that the up vector is orthogonal to the direction vector and both are normalized void stabalize() { - vec side = up.cross(d); + vec3 side = up.cross(d); up = d.cross(side); up = up.norm(); d = d.norm(); } public: - void setPosition(vec pos) + void setPosition(vec3 pos) { p = pos; } - void setPosition(float x, float y, float z){setPosition(vec(x, y, z));} + void setPosition(float x, float y, float z){setPosition(vec3(x, y, z));} void setFocalDistance(float distance){focus = distance;} void setFOV(float field_of_view){fov = field_of_view;} - void LookAt(vec pos) + void LookAt(vec3 pos) { //find the new direction d = pos - p; @@ -47,22 +47,22 @@ public: //stabalize the camera stabalize(); } - void LookAt(float px, float py, float pz){LookAt(vec(px, py, pz));} - void LookAt(vec pos, vec new_up){up = new_up; LookAt(pos);} - void LookAt(float px, float py, float pz, float ux, float uy, float uz){LookAt(vec(px, py, pz), vec(ux, uy, uz));} + void LookAt(float px, float py, float pz){LookAt(vec3(px, py, pz));} + void LookAt(vec3 pos, vec3 new_up){up = new_up; LookAt(pos);} + void LookAt(float px, float py, float pz, float ux, float uy, float uz){LookAt(vec3(px, py, pz), vec3(ux, uy, uz));} void LookAtDolly(float lx, float ly, float lz) { //find the current focus point - vec f = p + focus*d; - vec T = vec(lx, ly, lz) - f; + vec3 f = p + focus*d; + vec3 T = vec3(lx, ly, lz) - f; p = p + T; } - void Dolly(vec direction) + void Dolly(vec3 direction) { p = p+direction; } - void Dolly(float x, float y, float z){Dolly(vec(x, y, z));} + void Dolly(float x, float y, float z){Dolly(vec3(x, y, z));} void Push(float delta) { if(delta > focus) @@ -80,7 +80,7 @@ public: qx.CreateRotation(theta_x, up[0], up[1], up[2]); //y rotation is around the side axis - vec side = up.cross(d); + vec3 side = up.cross(d); quaternion qy; qy.CreateRotation(theta_y, side[0], side[1], side[2]); @@ -118,28 +118,28 @@ public: void OrbitFocus(float theta_x, float theta_y) { //find the focal point - vec focal_point = p + focus*d; + vec3 focal_point = p + focus*d; //center the coordinate system on the focal point - vec centered = p - (focal_point - vec(0, 0, 0)); + vec3 centered = p - (focal_point - vec3(0, 0, 0)); //create the x rotation (around the up vector) quaternion qx; qx.CreateRotation(theta_x, up[0], up[1], up[2]); - centered = vec(0, 0, 0) + qx.toMatrix3()*(centered - vec(0, 0, 0)); + centered = vec3(0, 0, 0) + qx.toMatrix3()*(centered - vec3(0, 0, 0)); //get a side vector for theta_y rotation - vec side = up.cross((vec(0, 0, 0) - centered).norm()); + vec3 side = up.cross((vec3(0, 0, 0) - centered).norm()); quaternion qy; qy.CreateRotation(theta_y, side[0], side[1], side[2]); - centered = vec(0, 0, 0) + qy.toMatrix3()*(centered - vec(0, 0, 0)); + centered = vec3(0, 0, 0) + qy.toMatrix3()*(centered - vec3(0, 0, 0)); //perform the rotation on the centered camera position //centered = final.toMatrix()*centered; //re-position the camera - p = centered + (focal_point - vec(0, 0, 0)); + p = centered + (focal_point - vec3(0, 0, 0)); //make sure we are looking at the focal point LookAt(focal_point); @@ -151,17 +151,17 @@ public: void Slide(float u, float v) { - vec V = up.norm(); - vec U = up.cross(d).norm(); + vec3 V = up.norm(); + vec3 U = up.cross(d).norm(); p = p + (V * v) + (U * u); } //accessor methods - vec getPosition(){return p;} - vec getUp(){return up;} - vec getDirection(){return d;} - vec getLookAt(){return p + focus*d;} + vec3 getPosition(){return p;} + vec3 getUp(){return up;} + vec3 getDirection(){return d;} + vec3 getLookAt(){return p + focus*d;} float getFOV(){return fov;} //output the camera settings @@ -182,9 +182,9 @@ public: //constructor camera() { - p = vec(0, 0, 0); - d = vec(0, 0, 1); - up = vec(0, 1, 0); + p = vec3(0, 0, 0); + d = vec3(0, 0, 1); + up = vec3(0, 1, 0); focus = 1; } diff --git a/stim/visualization/cylinder.h b/stim/visualization/cylinder.h index f203a77..a7b8662 100644 --- a/stim/visualization/cylinder.h +++ b/stim/visualization/cylinder.h @@ -2,7 +2,7 @@ #define STIM_CYLINDER_H #include #include -#include +#include namespace stim @@ -25,11 +25,11 @@ class cylinder ///inits the cylinder from a list of points (inP) and radii (inM) void - init(std::vector > inP, std::vector > inM) + init(std::vector > inP, std::vector > inM) { mags = inM; - stim::vec v1; - stim::vec v2; + stim::vec3 v1; + stim::vec3 v2; e.resize(inP.size()); if(inP.size() < 2) return; @@ -38,16 +38,16 @@ class cylinder L.resize(inP.size()); T temp = (T)0; L[0] = 0; - for(int i = 1; i < L.size(); i++) + for(size_t i = 1; i < L.size(); i++) { temp += (inP[i-1] - inP[i]).len(); L[i] = temp; } - stim::vec dr = (inP[1] - inP[0]).norm(); - s = stim::circle(inP[0], inM[0][0], dr, stim::vec(1,0,0)); + stim::vec3 dr = (inP[1] - inP[0]).norm(); + s = stim::circle(inP[0], inM[0][0], dr, stim::vec3(1,0,0)); e[0] = s; - for(int i = 1; i < inP.size()-1; i++) + for(size_t i = 1; i < inP.size()-1; i++) { s.center(inP[i]); v1 = (inP[i] - inP[i-1]).norm(); @@ -67,7 +67,7 @@ class cylinder } ///returns the direction vector at point idx. - stim::vec + stim::vec3 d(int idx) { if(idx == 0) @@ -81,15 +81,15 @@ class cylinder else { // return (e[idx+1].P - e[idx].P).norm(); - stim::vec v1 = (e[idx].P-e[idx-1].P).norm(); - stim::vec v2 = (e[idx+1].P-e[idx].P).norm(); + stim::vec3 v1 = (e[idx].P-e[idx-1].P).norm(); + stim::vec3 v2 = (e[idx+1].P-e[idx].P).norm(); return (v1+v2).norm(); } // return e[idx].N; } - stim::vec + stim::vec3 d(T l, int idx) { if(idx == 0 || idx == e.size()-1) @@ -144,13 +144,13 @@ class cylinder ///constructor to create a cylinder from a set of points, radii, and the number of sides for the cylinder. ///@param inP: Vector of stim vecs composing the points of the centerline. ///@param inM: Vector of stim vecs composing the radii of the centerline. - cylinder(std::vector > inP, std::vector > inM){ + cylinder(std::vector > inP, std::vector > inM){ init(inP, inM); } ///Constructor defines a cylinder with centerline inP and magnitudes of zero ///@param inP: Vector of stim vecs composing the points of the centerline - cylinder(std::vector< stim::vec > inP){ + cylinder(std::vector< stim::vec3 > inP){ std::vector< stim::vec > inM; //create an array of arbitrary magnitudes stim::vec zero; @@ -171,12 +171,12 @@ class cylinder ///Returns a position vector at the given p-value (p value ranges from 0 to 1). ///interpolates the position along the line. ///@param pvalue: the location of the in the cylinder, from 0 (beginning to 1). - stim::vec + stim::vec3 p(T pvalue) { if(pvalue < 0.0 || pvalue > 1.0) { - return stim::vec(-1,-1,-1); + return stim::vec3(-1,-1,-1); } T l = pvalue*L[L.size()-1]; int idx = findIdx(l); @@ -188,7 +188,7 @@ class cylinder ///Interpolates the radius along the line. ///@param l: the location of the in the cylinder. ///@param idx: integer location of the point closest to l but prior to it. - stim::vec + stim::vec3 p(T l, int idx) { T rat = (l-L[idx])/(L[idx+1]-L[idx]); @@ -252,16 +252,16 @@ class cylinder ///in x, y, z coordinates. Theta is in degrees from 0 to 360. ///@param pvalue: the location of the in the cylinder, from 0 (beginning to 1). ///@param theta: the angle to the point of a circle. - stim::vec + stim::vec3 surf(T pvalue, T theta) { if(pvalue < 0.0 || pvalue > 1.0) { - return stim::vec(-1,-1,-1); + return stim::vec3(-1,-1,-1); } else { T l = pvalue*L[L.size()-1]; int idx = findIdx(l); - stim::vec ps = p(l, idx); + stim::vec3 ps = p(l, idx); T m = r(l, idx); s = e[idx]; s.center(ps); @@ -273,10 +273,10 @@ class cylinder ///returns a vector of points necessary to create a circle at every position in the fiber. ///@param sides: the number of sides of each circle. - std::vector > > + std::vector > > getPoints(int sides) { - std::vector > > points; + std::vector > > points; points.resize(e.size()); for(int i = 0; i < e.size(); i++) { @@ -293,7 +293,7 @@ class cylinder } /// Allows a point on the centerline to be accessed using bracket notation - vec operator[](unsigned int i){ + vec3 operator[](unsigned int i){ return e[i].P; } @@ -309,7 +309,7 @@ class cylinder T M = 0; //initialize the integral to zero T m0, m1; //allocate space for both magnitudes in a single segment - //vec p0, p1; //allocate space for both points in a single segment + //vec3 p0, p1; //allocate space for both points in a single segment m0 = mags[0][m]; //initialize the first point and magnitude to the first point in the cylinder //p0 = pos[0]; @@ -325,7 +325,7 @@ class cylinder if(p > 1) len = (L[p-1] - L[p-2]); //calculate the segment length using the L array //add the average magnitude, weighted by the segment length - M += (m0 + m1)/2.0 * len; + M += (m0 + m1)/(T)2.0 * len; m0 = m1; //move to the next segment by shifting points } @@ -345,21 +345,21 @@ class cylinder /// @param spacing is the maximum spacing allowed between sample points cylinder resample(T spacing){ - std::vector< vec > result; + std::vector< vec3 > result; - vec p0 = e[0].P; //initialize p0 to the first point on the centerline - vec p1; + vec3 p0 = e[0].P; //initialize p0 to the first point on the centerline + vec3 p1; unsigned N = size(); //number of points in the current centerline //for each line segment on the centerline for(unsigned int i = 1; i < N; i++){ p1 = e[i].P; //get the second point in the line segment - vec v = p1 - p0; //calculate the vector between these two points + vec3 v = p1 - p0; //calculate the vector between these two points T d = v.len(); //calculate the distance between these two points (length of the line segment) - unsigned nsteps = d / spacing+1; //calculate the number of steps to take along the segment to meet the spacing criteria - T stepsize = 1.0 / nsteps; //calculate the parametric step size between new centerline points + size_t nsteps = (size_t)std::ceil(d / spacing); //calculate the number of steps to take along the segment to meet the spacing criteria + T stepsize = (T)1.0 / nsteps; //calculate the parametric step size between new centerline points //for each step along the line segment for(unsigned s = 0; s < nsteps; s++){ -- libgit2 0.21.4