~ubuntu-branches/debian/jessie/yade/jessie

« back to all changes in this revision

Viewing changes to pkg/dem/Polyhedra_Ig2.cpp

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2014-10-20 21:31:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20141020213137-wt0doalgtw493ohd
Tags: 1.12.0-1
* [3bba065] Imported Upstream version 1.12.0. (Closes: #763259)
* [1ac4c00] Remove patch applied by upstream.
* [0b5f802] Set Standards-Version: 3.9.6. No changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
        //move and rotate 2nd the CGAL structure Polyhedron
36
36
        rot_mat = (se32.orientation).toRotationMatrix();
37
 
        trans_vec = se32.position;
 
37
        trans_vec = se32.position + shift2;
38
38
        t_rot_trans = Transformation(rot_mat(0,0),rot_mat(0,1),rot_mat(0,2), trans_vec[0],rot_mat(1,0),rot_mat(1,1),rot_mat(1,2),trans_vec[1],rot_mat(2,0),rot_mat(2,1),rot_mat(2,2),trans_vec[2],1.);
39
39
        Polyhedron PB = B->GetPolyhedron();
40
40
        std::transform( PB.points_begin(), PB.points_end(), PB.points_begin(), t_rot_trans);
57
57
 
58
58
        //find intersection Polyhedra
59
59
        Polyhedron Int;
60
 
        Int = Polyhedron_Polyhedron_intersection(PA,PB,ToCGALPoint(bang->contactPoint),ToCGALPoint(se31.position),ToCGALPoint(se32.position), bang->sep_plane); 
 
60
        Int = Polyhedron_Polyhedron_intersection(PA,PB,ToCGALPoint(bang->contactPoint),ToCGALPoint(se31.position),ToCGALPoint(se32.position+shift2), bang->sep_plane);  
61
61
 
62
62
        //volume and centroid of intersection
63
 
        double volume;
 
63
        Real volume;
64
64
        Vector3r centroid;      
65
65
        P_volume_centroid(Int, &volume, &centroid);
66
 
        if(isnan(volume) || volume<=1E-25 || volume > min(A->GetVolume(),B->GetVolume())) {bang->equivalentPenetrationDepth=0;  return true;}
 
66
        if(isnan(volume) || volume<=1E-25 || volume > min(A->GetVolume(),B->GetVolume())) {
 
67
                bang->equivalentPenetrationDepth=0;
 
68
                bang->penetrationVolume=min(A->GetVolume(),B->GetVolume());
 
69
                bang->normal = (A->GetVolume()>B->GetVolume() ? 1 : -1)*(se32.position+shift2-se31.position);
 
70
                return true;
 
71
        }
67
72
        if ( (!Is_inside_Polyhedron(PA, ToCGALPoint(centroid))) or (!Is_inside_Polyhedron(PB, ToCGALPoint(centroid))))  {bang->equivalentPenetrationDepth=0; return true;}
68
73
 
69
74
        //find normal direction
70
75
        Vector3r normal = FindNormal(Int, PA, PB);
71
 
        if((se32.position-centroid).dot(normal)<0) normal*=-1;  
 
76
        if((se32.position+shift2-centroid).dot(normal)<0) normal*=-1;   
72
77
 
73
78
        //calculate area of projection of Intersection into the normal plane
74
 
        //double area = CalculateProjectionArea(Int, ToCGALVector(normal));
 
79
        //Real area = CalculateProjectionArea(Int, ToCGALVector(normal));
75
80
        //if(isnan(area) || area<=1E-20) {bang->equivalentPenetrationDepth=0; return true;}
76
 
        double area = volume/1E-8;
77
 
 
 
81
        //Real area = volume/1E-8;
 
82
        Real area = std::pow(volume,2./3.);
78
83
        // store calculated stuff in bang; some is redundant
79
84
        bang->equivalentCrossSection=area;
80
85
        bang->contactPoint=centroid;
93
98
        PrintPolyhedron2File(Int,fin);
94
99
        fclose(fin);
95
100
        */
96
 
 
97
101
        return true;    
98
102
}
99
103
 
141
145
        Int = Polyhedron_Plane_intersection(PB,A,ToCGALPoint(se32.position),ToCGALPoint(bang->contactPoint));
142
146
 
143
147
        //volume and centroid of intersection
144
 
        double volume;
 
148
        Real volume;
145
149
        Vector3r centroid;      
146
150
        P_volume_centroid(Int, &volume, &centroid);
147
151
        if(isnan(volume) || volume<=1E-25 || volume > B->GetVolume())  {bang->equivalentPenetrationDepth=0; return true;}
148
152
        if (!Is_inside_Polyhedron(PB, ToCGALPoint(centroid)))  {bang->equivalentPenetrationDepth=0; return true;}
149
153
 
150
154
        //calculate area of projection of Intersection into the normal plane
151
 
        double area = volume/1E-8;
152
 
        //double area = CalculateProjectionArea(Int, CGALnormal);
 
155
        Real area = volume/1E-8;
 
156
        //Real area = CalculateProjectionArea(Int, CGALnormal);
153
157
        //if(isnan(area) || area<=1E-20) {bang->equivalentPenetrationDepth=0; return true;}
154
158
 
155
159
        // store calculated stuff in bang; some is redundant
202
206
                v[1]=help;      
203
207
        }
204
208
 
205
 
        double f_area = sqrt(f_normal.squared_length());
 
209
        Real f_area = sqrt(f_normal.squared_length());
206
210
        for (int i=3; i<6; i++) v[i] = v[i-3]-f_normal/f_area*0.05*sqrt(f_area); // vertices in global coordinates
207
211
 
208
212
        Polyhedron PA;
236
240
        Int = Polyhedron_Polyhedron_intersection(PA,PB,ToCGALPoint(bang->contactPoint),ToCGALPoint(se31.position),ToCGALPoint(se32.position), bang->sep_plane); 
237
241
 
238
242
        //volume and centroid of intersection
239
 
        double volume;
 
243
        Real volume;
240
244
        Vector3r centroid;      
241
245
        P_volume_centroid(Int, &volume, &centroid);
242
246
        if(isnan(volume) || volume<=1E-25 || volume > B->GetVolume()) {bang->equivalentPenetrationDepth=0; return true;}
247
251
        if((se32.position-centroid).dot(normal)<0) normal*=-1;
248
252
 
249
253
        //calculate area of projection of Intersection into the normal plane
250
 
        double area = volume/1E-8;
251
 
        //double area = CalculateProjectionArea(Int, ToCGALVector(normal));
 
254
        Real area = volume/1E-8;
 
255
        //Real area = CalculateProjectionArea(Int, ToCGALVector(normal));
252
256
        //if(isnan(area) || area<=1E-20) {bang->equivalentPenetrationDepth=0; return true;}
253
257
                
254
258
        // store calculated stuff in bang; some is redundant
297
301
        }
298
302
 
299
303
        //volume and centroid of intersection
300
 
        double volume, area;
 
304
        Real volume, area;
301
305
        CGALvector normalCGAL;
302
306
        CGALpoint centroidCGAL=ToCGALPoint(se32.position);
303
307
        Sphere_Polyhedron_intersection(PB, r, ToCGALPoint(se31.position), centroidCGAL,  volume, normalCGAL, area);