Précédent   Forum des professionnels en informatique > Bases de données > Oracle > PL/SQL
PL/SQL Forum d'entraide sur le PL/SQL
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 05/05/2011, 12h01   #1
Membre habitué
 
Inscription : avril 2004
Messages : 363
Détails du profil
Informations forums :
Inscription : avril 2004
Messages : 363
Points : 121
Points : 121
Par défaut Recherche d'API pour calcul matriciel, vectoriel et quaternions

Bonjour,

Je recherche des packages PL/SQL pour effectuer des calculs mathématiques sur les matrices, vecteurs et quaternions.

Savez-vous s'il existe de tels packages ou API quelque part ?

Bien à vous.
patmaba est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/05/2011, 14h22   #2
Expert Confirmé Sénior
 
Avatar de mnitu
 
Homme Marius Nitu
Ingénieur développement logiciels
Inscription : octobre 2007
Messages : 3 311
Détails du profil
Informations personnelles :
Nom : Homme Marius Nitu
Localisation : France, Marne (Champagne Ardenne)

Informations professionnelles :
Activité : Ingénieur développement logiciels
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : octobre 2007
Messages : 3 311
Points : 5 808
Points : 5 808
UTL_NA
mnitu est déconnecté   Envoyer un message privé Réponse avec citation 20
Vieux 05/05/2011, 15h15   #3
Membre habitué
 
Inscription : avril 2004
Messages : 363
Détails du profil
Informations forums :
Inscription : avril 2004
Messages : 363
Points : 121
Points : 121
merci pour votre réponse. Je ne connaissais pas ce package.

l'idée est d'avoir un appel de procedure/fonctions pl/sql proche du code c ci -dessous provenant du langage c.


Code C :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
#ifndef GEOM_H
#define GEOM_H
 
#include <math.h>
 
class Vector;
class Line;
class Plane;
class Matrix;
class Transform;
 
const float PI=3.14159265359f;        //180 degrees
const float TWOPI=PI*2.0f;            //360 degrees
const float HALFPI=PI*.5f;            //90  degrees
const float QUARTERPI=PI*.25f;        //45  degrees
const float EPSILON=.000001f;        //small value
const float INFINITY=10000000.0f;    //big value
 
class Vector{
public:
    float x,y,z;
 
    Vector():x(0),y(0),z(0){
    }
    Vector( float x,float y,float z ):x(x),y(y),z(z){
    }
    operator float*(){
        return &x;
    }
    operator const float *(){
        return &x;
    }
    float &operator[]( int n ){
        return (&x)[n]; 
    }
    float operator[]( int n )const{
        return (&x)[n]; 
    }
    Vector operator-()const{
        return Vector( -x,-y,-z ); 
    }
    Vector operator*( float scale )const{
        return Vector( x*scale,y*scale,z*scale );
    }
    Vector operator*( const Vector &q )const{
        return Vector( x*q.x,y*q.y,z*q.z );
    }
    Vector operator/( float scale )const{
        return Vector( x/scale,y/scale,z/scale );
    }
    Vector operator/( const Vector &q )const{
        return Vector( x/q.x,y/q.y,z/q.z );
    }
    Vector operator+( const Vector &q )const{
        return Vector( x+q.x,y+q.y,z+q.z );
    }
    Vector operator-( const Vector &q )const{
        return Vector( x-q.x,y-q.y,z-q.z );
    }
    Vector &operator*=( float scale ){
        x*=scale;y*=scale;z*=scale;return *this;
    }
    Vector &operator*=( const Vector &q ){
        x*=q.x;y*=q.y;z*=q.z;return *this;
    }
    Vector &operator/=( float scale ){
        x/=scale;y/=scale;z/=scale;return *this;
    }
    Vector &operator/=( const Vector &q ){
        x/=q.x;y/=q.y;z/=q.z;return *this;
    }
    Vector &operator+=( const Vector &q ){
        x+=q.x;y+=q.y;z+=q.z;return *this;
    }
    Vector &operator-=( const Vector &q ){
        x-=q.x;y-=q.y;z-=q.z;return *this;
    }
    bool operator<( const Vector &q )const{
        if( fabs(x-q.x)>EPSILON ) return x<q.x ? true : false;
        if( fabs(y-q.y)>EPSILON ) return y<q.y ? true : false;
        return fabs(z-q.z)>EPSILON && z<q.z;
    }
    bool operator==( const Vector &q )const{
        return fabs(x-q.x)<=EPSILON && fabs(y-q.y)<=EPSILON && fabs(z-q.z)<=EPSILON;
    }
    bool operator!=( const Vector &q )const{
        return fabs(x-q.x)>EPSILON || fabs(y-q.y)>EPSILON || fabs(z-q.z)>EPSILON;
    }
    float dot( const Vector &q )const{
        return x*q.x+y*q.y+z*q.z;
    }
    Vector cross( const Vector &q )const{
        return Vector( y*q.z-z*q.y,z*q.x-x*q.z,x*q.y-y*q.x );
    }
    float length()const{
        return sqrtf(x*x+y*y+z*z);
    }
    float distance( const Vector &q )const{
        float dx=x-q.x,dy=y-q.y,dz=z-q.z;return sqrtf(dx*dx+dy*dy+dz*dz);
    }
    Vector normalized()const{
        float l=length();return Vector( x/l,y/l,z/l );
    }
    void normalize(){
        float l=length();x/=l;y/=l;z/=l;
    }
    float yaw()const{
        return -atan2f( x,z );
    }
    float pitch()const{
        return -atan2f( y,sqrtf( x*x+z*z ) );
    }
    void clear(){
        x=y=z=0;
    }
};
 
class Line{
public:
    Vector o,d;
    Line(){
    }
    Line( const Vector &o,const Vector &d ):o(o),d(d){
    }
    Line operator+( const Vector &q )const{
        return Line( o+q,d );
    }
    Line operator-( const Vector &q )const{
        return Line( o-q,d );
    }
    Vector operator*( float q )const{
        return o+d*q;
    }
    Vector nearest( const Vector &q )const{
        return o+d*(d.dot(q-o)/d.dot(d));
    }
};
 
class Plane{
public:
    Vector n;
    float d;
 
    Plane():d(0){
    }
    //normal/offset form
    Plane( const Vector &n,float d ):n(n),d(d){
    }
    //point/normal form
    Plane( const Vector &p,const Vector &n ):n(n),d(-n.dot(p)){
    }
    //create plane from tri
    Plane( const Vector &v0,const Vector &v1,const Vector &v2 ){
        n=(v1-v0).cross(v2-v0).normalized();d=-n.dot(v0);
    }
    Plane operator-()const{
        return Plane( -n,-d );
    }
    float t_intersect( const Line &q )const{
        return -distance(q.o)/n.dot(q.d);
    }
    Vector intersect( const Line &q )const{
        return q*t_intersect(q);
    }
    Line intersect( const Plane &q )const{
        Vector lv=n.cross( q.n ).normalized();
        return Line( q.intersect( Line( nearest( n*-d ),n.cross(lv) ) ),lv );
    }
    Vector nearest( const Vector &q )const{
        return q-n*distance(q);
    }
    void negate(){
        n=-n;d=-d;
    }
    float distance( const Vector &q )const{
        return n.dot(q)+d;
    }
};
 
struct Quat{
    float w;
    Vector v;
    Quat():w(1){
    }
    Quat( float w,const Vector &v ):w(w),v(v){
    }
    Quat operator-()const{
        return Quat( w,-v );
    }
    Quat operator+( const Quat &q )const{
        return Quat( w+q.w,v+q.v );
    }
    Quat operator-( const Quat &q )const{
        return Quat( w-q.w,v-q.v );
    }
    Quat operator*( const Quat &q )const{
        return Quat( w*q.w-v.dot(q.v),q.v.cross(v)+q.v*w+v*q.w );
    }
    Vector operator*( const Vector &q )const{
        return (*this * Quat(0,q) * -*this).v;
    }
    Quat operator*( float q )const{
        return Quat( w*q,v*q );
    }
    Quat operator/( float q )const{
        return Quat( w/q,v/q );
    }
    float dot( const Quat &q )const{
        return v.x*q.v.x+v.y*q.v.y+v.z*q.v.z+w*q.w;
    }
    float length()const{
        return sqrtf( w*w+v.x*v.x+v.y*v.y+v.z*v.z );
    }
    void normalize(){
        *this=*this/length();
    }
    Quat normalized()const{
        return *this/length();
    }
    Quat slerpTo( const Quat &q,float a )const{
        Quat t=q;
        float d=dot(q),b=1-a;
        if( d<0 ){ t.w=-t.w;t.v=-t.v;d=-d; }
        if( d<1-EPSILON ){
            float om=acosf( d );
            float si=sinf( om );
            a=sinf( a*om )/si;
            b=sinf( b*om )/si;
        }
        return *this*b + t*a;
    }
    Vector i()const{
        float xz=v.x*v.z,wy=w*v.y;
        float xy=v.x*v.y,wz=w*v.z;
        float yy=v.y*v.y,zz=v.z*v.z;
        return Vector( 1-2*(yy+zz),2*(xy-wz),2*(xz+wy) );
    }
    Vector j()const{
        float yz=v.y*v.z,wx=w*v.x;
        float xy=v.x*v.y,wz=w*v.z;
        float xx=v.x*v.x,zz=v.z*v.z;
        return Vector( 2*(xy+wz),1-2*(xx+zz),2*(yz-wx) );
    }
    Vector k()const{
        float xz=v.x*v.z,wy=w*v.y;
        float yz=v.y*v.z,wx=w*v.x;
        float xx=v.x*v.x,yy=v.y*v.y;
        return Vector( 2*(xz-wy),2*(yz+wx),1-2*(xx+yy) );
    }
};
 
class Matrix{
    static Matrix tmps[64];
    static Matrix &alloc_tmp(){ static int tmp=0;return tmps[tmp++&63];    }
    friend class Transform;
public:
    Vector i,j,k;
 
    Matrix():i(Vector(1,0,0)),j(Vector(0,1,0)),k(Vector(0,0,1)){
    }
    Matrix( const Vector &i,const Vector &j,const Vector &k ):i(i),j(j),k(k){
    }
    Matrix( const Quat &q ){
        float xx=q.v.x*q.v.x,yy=q.v.y*q.v.y,zz=q.v.z*q.v.z;
        float xy=q.v.x*q.v.y,xz=q.v.x*q.v.z,yz=q.v.y*q.v.z;
        float wx=q.w*q.v.x,wy=q.w*q.v.y,wz=q.w*q.v.z;
        i=Vector( 1-2*(yy+zz),2*(xy-wz),2*(xz+wy) ),
        j=Vector( 2*(xy+wz),1-2*(xx+zz),2*(yz-wx) ),
        k=Vector( 2*(xz-wy),2*(yz+wx),1-2*(xx+yy) );
    }
    Matrix( float angle,const Vector &axis ){
        const Vector &u=axis;
        float c=cosf(angle),s=sinf(angle);
        float x2=axis.x*axis.x,y2=axis.y*axis.y,z2=axis.z*axis.z;
        i=Vector( x2+c*(1-x2),u.x*u.y*(1-c)-u.z*s,u.z*u.x*(1-c)+u.y*s );
        j=Vector( u.x*u.y*(1-c)+u.z*s,y2+c*(1-y2),u.y*u.z*(1-c)-u.x*s );
        k=Vector( u.z*u.x*(1-c)-u.y*s,u.y*u.z*(1-c)+u.x*s,z2+c*(1-z2) );
    }
    Vector &operator[]( int n ){
        return (&i)[n]; 
    }
    const Vector &operator[]( int n )const{
        return (&i)[n];
    }
    Matrix &operator~()const{
        Matrix &m=alloc_tmp();
        m.i.x=i.x;m.i.y=j.x;m.i.z=k.x;
        m.j.x=i.y;m.j.y=j.y;m.j.z=k.y;
        m.k.x=i.z;m.k.y=j.z;m.k.z=k.z;
        return m;
    }
    float determinant()const{
        return i.x*(j.y*k.z-j.z*k.y )-i.y*(j.x*k.z-j.z*k.x )+i.z*(j.x*k.y-j.y*k.x );
    }
    Matrix &operator-()const{
        Matrix &m=alloc_tmp();
        float t=1.0f/determinant();
        m.i.x= t*(j.y*k.z-j.z*k.y);m.i.y=-t*(i.y*k.z-i.z*k.y);m.i.z= t*(i.y*j.z-i.z*j.y);
        m.j.x=-t*(j.x*k.z-j.z*k.x);m.j.y= t*(i.x*k.z-i.z*k.x);m.j.z=-t*(i.x*j.z-i.z*j.x);
        m.k.x= t*(j.x*k.y-j.y*k.x);m.k.y=-t*(i.x*k.y-i.y*k.x);m.k.z= t*(i.x*j.y-i.y*j.x);
        return m;
    }
    Matrix &cofactor()const{
        Matrix &m=alloc_tmp();
        m.i.x= (j.y*k.z-j.z*k.y);m.i.y=-(j.x*k.z-j.z*k.x);m.i.z= (j.x*k.y-j.y*k.x);
        m.j.x=-(i.y*k.z-i.z*k.y);m.j.y= (i.x*k.z-i.z*k.x);m.j.z=-(i.x*k.y-i.y*k.x);
        m.k.x= (i.y*j.z-i.z*j.y);m.k.y=-(i.x*j.z-i.z*j.x);m.k.z= (i.x*j.y-i.y*j.x);
        return m;
    }
    bool operator==( const Matrix &q )const{
        return i==q.i && j==q.j && k==q.k;
    }
    bool operator!=( const Matrix &q )const{
        return i!=q.i || j!=q.j || k!=q.k;
    }
    Vector operator*( const Vector &q )const{
        return Vector( i.x*q.x+j.x*q.y+k.x*q.z,i.y*q.x+j.y*q.y+k.y*q.z,i.z*q.x+j.z*q.y+k.z*q.z );
    }
    Matrix &operator*( const Matrix &q )const{
        Matrix &m=alloc_tmp();
        m.i.x=i.x*q.i.x+j.x*q.i.y+k.x*q.i.z;m.i.y=i.y*q.i.x+j.y*q.i.y+k.y*q.i.z;m.i.z=i.z*q.i.x+j.z*q.i.y+k.z*q.i.z;
        m.j.x=i.x*q.j.x+j.x*q.j.y+k.x*q.j.z;m.j.y=i.y*q.j.x+j.y*q.j.y+k.y*q.j.z;m.j.z=i.z*q.j.x+j.z*q.j.y+k.z*q.j.z;
        m.k.x=i.x*q.k.x+j.x*q.k.y+k.x*q.k.z;m.k.y=i.y*q.k.x+j.y*q.k.y+k.y*q.k.z;m.k.z=i.z*q.k.x+j.z*q.k.y+k.z*q.k.z;
        return m;
    }
    void orthogonalize(){
        k.normalize();
        i=j.cross( k ).normalized();
        j=k.cross( i );
    }
    Matrix &orthogonalized()const{
        Matrix &m=alloc_tmp();
        m=*this;m.orthogonalize();
        return m;
    }
};
 
class Box{
public:
    Vector a,b;
    Box():a( Vector(INFINITY,INFINITY,INFINITY) ),b( Vector(-INFINITY,-INFINITY,-INFINITY) ){
    }
    Box( const Vector &q ):a(q),b(q){
    }
    Box( const Vector &a,const Vector &b ):a(a),b(b){
    }
    Box( const Line &l ):a(l.o),b(l.o){
        update( l.o+l.d );
    }
    void clear(){
        a.x=a.y=a.z=INFINITY;
        b.x=b.y=b.z=-INFINITY;
    }
    bool empty()const{
        return b.x<a.x || b.y<a.y || b.z<a.z;
    }
    Vector centre()const{
        return Vector( (a.x+b.x)*.5f,(a.y+b.y)*.5f,(a.z+b.z)*.5f );
    }
    Vector corner( int n )const{
        return Vector( ((n&1)?b:a).x,((n&2)?b:a).y,((n&4)?b:a).z );
    }
    void update( const Vector &q ){
        if( q.x<a.x ) a.x=q.x;if( q.y<a.y ) a.y=q.y;if( q.z<a.z ) a.z=q.z;
        if( q.x>b.x ) b.x=q.x;if( q.y>b.y ) b.y=q.y;if( q.z>b.z ) b.z=q.z;
    }
    void update( const Box &q ){
        if( q.a.x<a.x ) a.x=q.a.x;if( q.a.y<a.y ) a.y=q.a.y;if( q.a.z<a.z ) a.z=q.a.z;
        if( q.b.x>b.x ) b.x=q.b.x;if( q.b.y>b.y ) b.y=q.b.y;if( q.b.z>b.z ) b.z=q.b.z;
    }
    bool overlaps( const Box &q )const{
        return
        (b.x<q.b.x?b.x:q.b.x)>=(a.x>q.a.x?a.x:q.a.x) &&
        (b.y<q.b.y?b.y:q.b.y)>=(a.y>q.a.y?a.y:q.a.y) &&
        (b.z<q.b.z?b.z:q.b.z)>=(a.z>q.a.z?a.z:q.a.z);
    }
    void expand( float n ){
        a.x-=n;a.y-=n;a.z-=n;b.x+=n;b.y+=n;b.z+=n;
    }
    float width()const{
        return b.x-a.x;
    }
    float height()const{
        return b.y-a.y;
    }
    float depth()const{
        return b.z-a.z;
    }
    bool contains( const Vector &q ){
        return q.x>=a.x && q.x<=b.x && q.y>=a.y && q.y<=b.y && q.z>=a.z && q.z<=b.z;
    }
};
 
class Transform{
    static Transform tmps[64];
    static Transform &alloc_tmp(){ static int tmp=0;return tmps[tmp++&63]; }
public:
    Matrix m;
    Vector v;
 
    Transform(){
    }
    Transform( const Matrix &m ):m(m){
    }
    Transform( const Vector &v ):v(v){
    }
    Transform( const Matrix &m,const Vector &v ):m(m),v(v){
    }
    Transform &operator-()const{
        Transform &t=alloc_tmp();
        t.m=-m;t.v=t.m*-v;
        return t;
    }
    Transform &operator~()const{
        Transform &t=alloc_tmp();
        t.m=~m;t.v=t.m*-v;
        return t;
    }
    Vector operator*( const Vector &q )const{
        return m*q+v;
    }
    Line operator*( const Line &q )const{
        Vector t=(*this)*q.o;
        return Line( t,(*this)*(q.o+q.d)-t );
    }
    Box operator*( const Box &q )const{
        Box t( (*this*q.corner(0) ) );
        for( int k=1;k<8;++k ) t.update( *this*q.corner(k) );
        return t;
    }
    Transform &operator*( const Transform &q )const{
        Transform &t=alloc_tmp();
        t.m=m*q.m;t.v=m*q.v+v;
        return t;
    }
    bool operator==( const Transform &q )const{
        return m==q.m && v==q.v;
    }
    bool operator!=( const Transform &q )const{
        return !operator==( q );
    }
};
 
inline float transformRadius( float r,const Matrix &t ){
    static const float sq_3=sqrtf(1.0f/3.0f);
    return (t * Vector( sq_3,sq_3,sq_3 )).length()*r;
}
 
inline Matrix pitchMatrix( float q ){
    return Matrix( Vector(1,0,0),Vector(0,cosf(q),sinf(q)),Vector(0,-sinf(q),cosf(q)) );
}
 
inline Matrix yawMatrix( float q ){
    return Matrix( Vector(cosf(q),0,sinf(q)),Vector(0,1,0),Vector(-sinf(q),0,cosf(q)) );
}
 
inline Matrix rollMatrix( float q ){
    return Matrix( Vector(cosf(q),sinf(q),0),Vector(-sinf(q),cosf(q),0),Vector(0,0,1) );
}
 
inline float matrixPitch( const Matrix &m ){
    return m.k.pitch();
}
 
inline float matrixYaw( const Matrix &m ){
    return m.k.yaw();
}
 
inline float matrixRoll( const Matrix &m ){
    return atan2f( m.i.y,m.j.y );
}
 
inline Matrix scaleMatrix( float x,float y,float z ){
    return Matrix( Vector( x,0,0 ),Vector( 0,y,0 ),Vector( 0,0,z ) );
}
 
inline Matrix scaleMatrix( const Vector &scale ){
    return Matrix( Vector( scale.x,0,0 ),Vector( 0,scale.y,0 ),Vector( 0,0,scale.z ) );
}
 
inline Quat pitchQuat( float p ){
    return Quat( cosf(p/-2),Vector( sinf(p/-2),0,0 ) );
}
 
inline Quat yawQuat( float y ){
    return Quat( cosf(y/2),Vector( 0,sinf(y/2),0 ) );
}
 
inline Quat rollQuat( float r ){
    return Quat( cosf(r/-2),Vector( 0,0,sinf(r/-2) ) );
}
 
inline Matrix rotationMatrix( float p,float y,float r ){
    return yawMatrix(y)*pitchMatrix(p)*rollMatrix(r);
}
 
inline Matrix rotationMatrix( const Vector &rot ){
    return yawMatrix(rot.y)*pitchMatrix(rot.x)*rollMatrix(rot.z);
}
 
inline float quatPitch( const Quat &q ){
    return q.k().pitch();
}
 
inline float quatYaw( const Quat &q ){
    return q.k().yaw();
}
 
inline float quatRoll( const Quat &q ){
    return matrixRoll( q );
}
 
inline Quat matrixQuat( const Matrix &p ){
    Matrix m=p;
    m.orthogonalize();
    float t=m.i.x+m.j.y+m.k.z,w,x,y,z;
    if( t>EPSILON ){
        t=sqrtf( t+1 )*2;
        x=(m.k.y-m.j.z)/t;
        y=(m.i.z-m.k.x)/t;
        z=(m.j.x-m.i.y)/t;
        w=t/4;
    }else if( m.i.x>m.j.y && m.i.x>m.k.z ){
        t=sqrtf( m.i.x-m.j.y-m.k.z+1 )*2;
        x=t/4;
        y=(m.j.x+m.i.y)/t;
        z=(m.i.z+m.k.x)/t;
        w=(m.k.y-m.j.z)/t;
    }else if( m.j.y>m.k.z ){
        t=sqrtf( m.j.y-m.k.z-m.i.x+1 )*2;
        x=(m.j.x+m.i.y)/t;
        y=t/4;
        z=(m.k.y+m.j.z)/t;
        w=(m.i.z-m.k.x)/t;
    }else{
        t=sqrtf( m.k.z-m.j.y-m.i.x+1 )*2;
        x=(m.i.z+m.k.x)/t;
        y=(m.k.y+m.j.z)/t;
        z=t/4;
        w=(m.j.x-m.i.y)/t;
    }
    return Quat( w,Vector( x,y,z ) );
}
 
#endif
patmaba est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/05/2011, 15h30   #4
Modérateur
 
Homme Fabien
Ingénieur d'études en décisionnel
Inscription : septembre 2008
Messages : 5 684
Détails du profil
Informations personnelles :
Nom : Homme Fabien
Âge : 34
Localisation : France, Yvelines (Île de France)

Informations professionnelles :
Activité : Ingénieur d'études en décisionnel
Secteur : Arts - Culture

Informations forums :
Inscription : septembre 2008
Messages : 5 684
Points : 10 442
Points : 10 442
Envoyer un message via ICQ à Waldar Envoyer un message via Skype™ à Waldar
Vous pouvez créer des fonctions C directement dans Oracle :
http://download.oracle.com/docs/cd/E...htm#LNPLS01370
__________________
Email : http://scr.im/waldar
Waldar est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/05/2011, 15h32   #5
Expert Confirmé Sénior
 
Avatar de mnitu
 
Homme Marius Nitu
Ingénieur développement logiciels
Inscription : octobre 2007
Messages : 3 311
Détails du profil
Informations personnelles :
Nom : Homme Marius Nitu
Localisation : France, Marne (Champagne Ardenne)

Informations professionnelles :
Activité : Ingénieur développement logiciels
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : octobre 2007
Messages : 3 311
Points : 5 808
Points : 5 808
C’est plutôt C++ que C.
Si vous avez une bonne bibliothèque C(++) essayez dans ce cas de l’utiliser via les appels PL/SQL des procédures externes. Mais, il y aurait du boulot.
mnitu est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/05/2011, 15h40   #6
Expert Confirmé Sénior
 
Avatar de mnitu
 
Homme Marius Nitu
Ingénieur développement logiciels
Inscription : octobre 2007
Messages : 3 311
Détails du profil
Informations personnelles :
Nom : Homme Marius Nitu
Localisation : France, Marne (Champagne Ardenne)

Informations professionnelles :
Activité : Ingénieur développement logiciels
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : octobre 2007
Messages : 3 311
Points : 5 808
Points : 5 808
Citation:
Envoyé par Waldar Voir le message
Vous pouvez créer des fonctions C directement dans Oracle ...
Hmmm, c'est un peu trop abusif de dire ça. En fait il va créer une fonction « enveloppe » PL/SQL permettant d'appeler une fonction se trouvant dans une bibliothèque dynamique écrite en C (ou autre langage).
mnitu est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/05/2011, 15h50   #7
Modérateur
 
Homme Fabien
Ingénieur d'études en décisionnel
Inscription : septembre 2008
Messages : 5 684
Détails du profil
Informations personnelles :
Nom : Homme Fabien
Âge : 34
Localisation : France, Yvelines (Île de France)

Informations professionnelles :
Activité : Ingénieur d'études en décisionnel
Secteur : Arts - Culture

Informations forums :
Inscription : septembre 2008
Messages : 5 684
Points : 10 442
Points : 10 442
Envoyer un message via ICQ à Waldar Envoyer un message via Skype™ à Waldar
J'ai vu ça dans la doc et ici ou là sur internet, mais je n'ai jamais eu à mettre en pratique.
Merci pour la clarification du procédé !
__________________
Email : http://scr.im/waldar
Waldar est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/05/2011, 21h24   #8
Membre habitué
 
Inscription : avril 2004
Messages : 363
Détails du profil
Informations forums :
Inscription : avril 2004
Messages : 363
Points : 121
Points : 121
Et si j'essaie de convertir le code en java ? Au pire, si je crée des types objet pl/sql avec les méthodes.
Est-ce une solution valable ?
patmaba est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/05/2011, 14h41   #9
Membre habitué
 
Inscription : avril 2004
Messages : 363
Détails du profil
Informations forums :
Inscription : avril 2004
Messages : 363
Points : 121
Points : 121
C'est la poisse.

J'essaie temps bien que mal de créer un type vector3 dans l'ide Oracle SQL developer.

J'ai des erreur d’exécution :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
CREATE OR REPLACE
TYPE vector3
AS
  OBJECT
  (
    x NUMBER,
    y NUMBER,
    z NUMBER,
    CONSTRUCTOR
  FUNCTION vector3(
      pin_x NUMBER,
      pin_y NUMBER,
      pin_z NUMBER)
    RETURN self
  AS
    result,
    member PROCEDURE PRINT
  );
 
CREATE OR REPLACE
TYPE BODY vector3
AS
  CONSTRUCTOR
FUNCTION vector3(
    pin_x NUMBER,
    pin_y NUMBER,
    pin_z NUMBER)
  RETURN SELF
AS
  result
IS
BEGIN
  SELF.x := pin_x;
  SELF.y := pin_y;
  SELF.z := pin_z;
  RETURN;
END;
member PROCEDURE PRINT
IS
BEGIN
  dbms_output.put_line('( '||x||' , '||y||' , '||z||' )');
END PRINT;
END;
l'execution
Code :
1
2
3
4
5
6
7
 
DECLARE
  v1 vector3;
BEGIN
  v1 := vector3(0,0,0);
  v1.print;
END;
l'éxécution


Citation:
Error starting at line 1 in command:
DECLARE
v1 vector3;
BEGIN
v1 := vector3(0,0,0);
v1.print;
END;
Error report:
ORA-06550: line 4, column 9:
PLS-00307: too many declarations of 'VECTOR3' match this call
ORA-06550: line 4, column 3:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
j'ai essayé avec
v1 := new vector3(0,0,0);

C'est pareil
patmaba est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/05/2011, 14h53   #10
Expert Confirmé Sénior
 
Avatar de mnitu
 
Homme Marius Nitu
Ingénieur développement logiciels
Inscription : octobre 2007
Messages : 3 311
Détails du profil
Informations personnelles :
Nom : Homme Marius Nitu
Localisation : France, Marne (Champagne Ardenne)

Informations professionnelles :
Activité : Ingénieur développement logiciels
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : octobre 2007
Messages : 3 311
Points : 5 808
Points : 5 808
Lire un peu la doc ça n'a jamais fait du mal à personne.
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
Connected TO Oracle DATABASE 10g Enterprise Edition Release 10.2.0.4.0 
Connected AS mni
 
SQL> SET serveroutput ON
SQL> 
SQL> CREATE OR REPLACE
  2  TYPE vector3
  3  AS
  4    OBJECT
  5    (
  6      x NUMBER,
  7      y NUMBER,
  8      z NUMBER,
  9      member PROCEDURE PRINT
 10    );
 11  /
 
Type created
SQL> CREATE OR REPLACE
  2  TYPE BODY vector3
  3  AS
  4  member PROCEDURE PRINT
  5  IS
  6  BEGIN
  7    dbms_output.put_line('( '||x||' , '||y||' , '||z||' )');
  8  END PRINT;
  9  END;
 10  /
 
Type body created
SQL> DECLARE
  2    v1 vector3;
  3  BEGIN
  4    v1 := vector3(0,0,0);
  5    v1.print;
  6  END;
  7  /
 
( 0 , 0 , 0 )
 
PL/SQL procedure successfully completed
 
SQL>
mnitu est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 06/05/2011, 15h39   #11
Membre habitué
 
Inscription : avril 2004
Messages : 363
Détails du profil
Informations forums :
Inscription : avril 2004
Messages : 363
Points : 121
Points : 121
C'est ce que j'ai fait en faisant référence à l'example du rectangle sur le lien officiel suivant :
http://download.oracle.com/docs/cd/B...07/10_objs.htm
patmaba est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/05/2011, 15h48   #12
Expert Confirmé Sénior
 
Avatar de mnitu
 
Homme Marius Nitu
Ingénieur développement logiciels
Inscription : octobre 2007
Messages : 3 311
Détails du profil
Informations personnelles :
Nom : Homme Marius Nitu
Localisation : France, Marne (Champagne Ardenne)

Informations professionnelles :
Activité : Ingénieur développement logiciels
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : octobre 2007
Messages : 3 311
Points : 5 808
Points : 5 808
Justement
Citation:
Defining Object Constructors
By default, you do not need to define a constructor for an object type. The system supplies a default constructor that accepts a parameter corresponding to each attribute.

You might also want to define your own constructor:

•To supply default values for some attributes. You can ensure the values are correct instead of relying on the caller to supply every attribute value.

•To avoid many special-purpose procedures that just initialize different parts of an object.

•To avoid code changes in applications that call the constructor, when new attributes are added to the type. The constructor might need some new code, for example to set the attribute to null, but its signature could remain the same so that existing calls to the constructor would continue to work.

For example:

CREATE OR REPLACE TYPE rectangle AS OBJECT
(
-- The type has 3 attributes.
length NUMBER,
width NUMBER,
area NUMBER,
-- Define a constructor that has only 2 parameters.
CONSTRUCTOR FUNCTION rectangle(length NUMBER, width NUMBER)
RETURN SELF AS RESULT
);
/
Allez bon courage.
mnitu est déconnecté   Envoyer un message privé Réponse avec citation 10
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 10h02.


 
 
 
 
Partenaires

Hébergement Web