Cat's machete

Member
  • Content count

    874
  • Joined

  • Last visited

Community Reputation

1452 Excellent

About Cat's machete

  • Rank
    >^_^<

Personal Information

  1. Physics behind briddge constructor

    Its just out of curiosity, if anyone ever played 'bridge constructor' game i wonder how forces are distributed? How do you calculate that, any papers describing distribution a force along these structures?
  2. template <class type, class type2> bool betweenorequal(type2 x1, type2 x2, type x0) { bool result = false; type a = smallerA(x1,x2); type b = greaterA(x1,x2); if ( ( a <= x0 ) && ( b >= x0 ) )result = true; else result = false; return result; } I did it like this, anyway your prevorious post pointed me that i should actually read carefully error msgs....
  3. C++ precision

    Ok then ;p inline AnsiString truncfstr(AnsiString text, AnsiString sign, int precision) { AnsiString s = text; AnsiString tmp; tmp = stddelete(s,Pos(sign,s)+sign.length()+precision, 10000000); return tmp; } inline int Pos(AnsiString sub, AnsiString str) { std::size_t found = str.find(sub,0); if (found!=AnsiString ::npos) return int(found)+1; else return 0; } inline AnsiString stddelete(AnsiString str, int pos, int len) //this is for AnsiString only because i will call only Pos()-1 from it { AnsiString s = str; s.erase(pos, len); return s; } Where typedef std::string AnsiString; Should work
  4. Ok this is actially my bad, i just couldn't imagine that this would compile with android ndk compile, but not with that compiler
  5. Make tris out of 2d set of points

    But since within first iteration we apply super triangle to outputpolygon and then use its edges to form new triangles they always contain a point within supertriangle...
  6. Lock camera on object

    void perform_rotation_to_vector(t3dpoint<float> vec, bool normalized) { t3dpoint<float> v; if (normalized == false) v = Normalize( vec ); else v = vec; t3dpoint<float> temp; temp = vector_multiple(v, 10000.0); t3dpoint<float> temp2; temp2 = vector_multiple(rf, 10000.0); float act_pitch; act_pitch = GetLatitude( temp2 ); float act_yaw; act_yaw = GetLongitude( temp2 ); act_pitch = VALIDUJ( act_pitch ); act_yaw = VALIDUJ( act_yaw ); //ShowMessage("act pitch: "+FloatToStr(act_pitch)); //ShowMessage("act yaw: "+FloatToStr(act_yaw)); float new_pitch; new_pitch = GetLatitude( temp ); float new_yaw; new_yaw = GetLongitude( temp ); new_pitch = VALIDUJ( new_pitch ); new_yaw = VALIDUJ( new_yaw ); // //ShowMessage("new pitch: "+FloatToStr(new_pitch)); //ShowMessage("new yaw: "+FloatToStr(new_yaw)); float yawsign = 1.0; float pitchsign = 1.0; float mpitch; if (act_pitch > new_pitch) mpitch = -(act_pitch - new_pitch); else { mpitch = new_pitch - act_pitch; pitchsign = -1.0; } float myaw; if (act_yaw > new_yaw) myaw = -(act_yaw - new_yaw); else { myaw = new_yaw - act_yaw; yawsign = -1.0; } float mpsine; float mpcosine; mpsine = sin( mpitch * imopi ); mpcosine = cos( mpitch * imopi ); float mysine; float mycosine; mysine = sin( myaw * imopi ); mycosine = cos( myaw * imopi ); if (mpitch < 0) pitchsign = -1.0; if (myaw < 0) yawsign = -1.0; yaw(mycosine,yawsign*mysine); DoRotation(); pitch(mpcosine,pitchsign*mpsine); DoRotation(); temp2 = vector_multiple(rf, 10000.0); act_pitch = GetLatitude( temp2 ); act_yaw = GetLongitude( temp2 ); //ShowMessage("act pitch: "+FloatToStr(act_pitch)); //ShowMessage("act yaw: "+FloatToStr(act_yaw)); } void perform_roll_to_vector(t3dpoint<float> vec, bool normalized) { t3dpoint<float> v; if (normalized == false) v = Normalize( vec ); else v = vec; t3dpoint<float> temp; temp = vector_multiple(v, 10000.0); t3dpoint<float> temp2; temp2.x = bx; temp2.y = by; temp2.z = bz; temp2 = vector_multiple(temp2, 10000.0); float angela = RAD_TO_DEG*( AngleBetweenVectors(temp, temp2) ) + 180.0; float mpsine; float mpcosine; mpsine = sin( angela * imopi ); mpcosine = cos( angela * imopi ); // float yawsign = 1.0; roll(mpcosine,mpsine); DoRotation(); } You need to define the initial vector direction i cant remember but this should be 0.0, 0.0, 1.0 or z was -1 Where template <class type> type aGetLongitude(t3dpoint<type> cpos) //poludniki (Dlugosc) { type angle; angle = n2dGetPolarCoordAngleA(cpos.x,cpos.z) / type(2.0*pi); angle = -360.0*angle; angle = VALIDUJ(angle)+90.0; angle = VALIDUJ(angle); return angle; } template <class type> type aGetLatitude(t3dpoint<type> cpos) { t3dpoint<type> cpn; cpn = Normalize(cpn); type t = cpn.x*cpn.x + cpn.z*cpn.z; t = sqrt(t); if (cpn.y == 0.0) return 0.0; type tanges = t / cpn.y; type angle; angle = atan(tanges); angle = RAD_TO_DEG * angle; if (angle < 0) angle = -1.0*(90.0 + angle); else angle = 90.0 - angle; return angle; } template <class type> double GetLongitudeLD(t3dpoint<type> cpos, t3dpoint<type> pos) //poludniki (Dlugosc) { double angle; angle = n2dGetPolarCoordAngleAD(( double)cpos.x-( double)pos.x,( double)cpos.z-( double)pos.z) / (pild*2.0); // angle = -360.0*angle; angle = VALIDUJ(angle)+90.0; angle = VALIDUJ(angle); return angle; } template <class type> double AngleBetween2Points(t3dpoint<type> cpos, t3dpoint<type> pos) //poludniki (Dlugosc) { double angle; angle = n2dGetPolarCoordAngleAD(( double)cpos.x-( double)pos.x,( double)cpos.z-( double)pos.z) / (pild*2.0); // angle = -360.0*angle; angle = VALIDUJ(angle); return angle; } template <class type> double GetLatitudeLD(t3dpoint<type> cpos, t3dpoint<type> pos) { t3dpoint<type> cpn; cpn = vectorAB(pos,cpos); cpn = Normalize(cpn); if (cpn.y == 0.0) return 0.0; double a = ( double)cpn.x; double b = ( double)cpn.z; double t = a*a+b*b; t = sqrt(t); double tanges = t / double(cpn.y); double angle; angle = atan(tanges); angle = angle * piimo; if (angle < 0) angle = -1.0*(90.0 + angle); else angle = 90.0 - angle; return angle; } template <class type> type n2dGetPolarCoordAngleA(type x,type y) { if ( (x > 0) && (y >= 0) ) { return atan(y/x); } if ( (x > 0) && (y < 0) ) { return atan(y/x)+2.0*3.1415926535897932384626433832795; } if (x < 0) { return atan(y/x)+3.1415926535897932384626433832795; } if ( (x == 0) && (y > 0) ) { return 3.1415926535897932384626433832795/2.0; } if ( (x == 0) && (y < 0) ) { return 3.0*3.1415926535897932384626433832795/2.0; } //last versions were without .0 just simple 2 division return - 1000.0; } inline double n2dGetPolarCoordAngleAD(double x,double y) { if ( (x == 0) && (y > 0) ) { return 3.1415926535897932384626433832795/2.0; } if ( (x == 0) && (y < 0) ) { return 3.0*3.1415926535897932384626433832795/2.0; } if (x == 0) return - 1000.0; double k; k = ( double)y / ( double)x; if ( (x > 0) && (y >= 0) ) { return atan(k); } if ( (x > 0) && (y < 0) ) { return atan(k)+2.0*3.1415926535897932384626433832795; } if (x < 0) { return atan(k)+3.1415926535897932384626433832795; } //last versions were without .0 just simple 2 division return - 1000.0; } But the best pick is to use matrices for that see glulookat function or search forum for my posts inshowed thencode
  7. C++ precision

    Better thing is to cut it like that that should work template <class type> type TruncX(type x, int len) { type denom = type(10.0); for (int i=0; i < len; i++) denom = denom * type(10.0); return type(int(x*denom) / denom); }
  8. A big stack of errors now i get Where template <class type> type greaterA(type a, type b) { if (a==b) return a; if (a>b) return a; else return b; } template <class type> type smallerA(type a, type b) { if (a==b) return a; if (a>b) return b; else return a; } /* * need strong optimization but first i need to check engine code */ template <class type, class type2> bool betweenorequal(type2 x1, type2 x2, type x0) { bool result = false; if (smallerA(x1,x2) <= x0) if (greaterA(x1,x2) >= x0) result = true; else result = false; return result; }
  9. Make tris out of 2d set of points

    Im currently looking for some easy explanation of this algorithm for now i see that this pseudocode just removes newly created triangle from list making empty triangle list, i am not quite sure if that pseudocode could even work For now what i get Having a set of point get min and max if y and x then create big triangle that covers whole pointset area make a circumcircle out of that tri. Add that tri to the output tri list Then loop through all verts for int i loop If a vertex is inside circumcircle of that super tri add that tri to badtri list Now for each edge in bad tri Check whenever other bad tri shares an edge if not add this not shared edge to some outputpolygon, so in first iteration it adds supertriangle to outputtrilist Now remove that bad triangle from tri list Now for each edge in outputpolygon form triangle to vert[ i ] Now if that newly formed triangle contains a vetex from super triangle remove that triangle ---- now thats where my brain blows off you just added a triangle only to remove it damn. Heres pseducode and below a link to code BowyerWatson (pointList) // pointList is a set of coordinates defining the points to be triangulated triangulation := empty triangle mesh data structure add super-triangle to triangulation // must be large enough to completely contain all the points in pointList for each point in pointList do // add all the points one at a time to the triangulation badTriangles := empty set for each triangle in triangulation do // first find all the triangles that are no longer valid due to the insertion if point is inside circumcircle of triangle add triangle to badTriangles polygon := empty set for each triangle in badTriangles do // find the boundary of the polygonal hole for each edge in triangle do if edge is not shared by any other triangles in badTriangles add edge to polygon for each triangle in badTriangles do // remove them from the data structure remove triangle from triangulation for each edge in polygon do // re-triangulate the polygonal hole newTri := form a triangle from edge to point add newTri to triangulation for each triangle in triangulation // done inserting points, now clean up if triangle contains a vertex from original super-triangle remove triangle from triangulation return triangulation https://github.com/Bl4ckb0ne/delaunay-triangulation/blob/master/delaunay.h This just doesnt make any sense... x_X
  10. Transforming Angular Velocity

    Either way you combine forces that cause object to rotate force1+force2+force And apply that to final acceleration from torque or correct me if im wrong (bit tired) you just add acceleration since its a vector
  11. Yes indeed i need an allocator, thankfully theres one default already defined so i dont need to care about rhings that are uselessbfor me i just need working compiler on my phone
  12. C++ [MAYA API] Getting all triangles from a polygon

    you could treat every face that has more than 3 verts as triangle fan polygon so you could put a vertex inside that polyand split it into triangles?
  13. Im sorry but it seems thebproblem is way more than just thisbline of code, however i was trying to compile header only where i got cpp file where this extern is defined too i wish you could just erase this topic
  14. extern std::vector <std::string> w_nawiasie[10]; can someone tell me why I get compilation error like /data/user/0/com.n0n3m4.droidc/files/temp.c:62:32: error: wrong number of template arguments (1, should be 2) extern std::vector <std::string> w_nawiasie[10]; ^ compilation terminated due to -Wfatal-errors.
  15. You iterate through all columns untill n column and you add all widths, this gives you exact posittion you can handle