亚洲二区精品_国产精品com_日本高清精品_国产高清一级毛片在线不卡
若楓后處理論壇
標(biāo)題:
APT刀軌數(shù)據(jù)生成NC程序C++源代碼
[打印本頁(yè)]
作者:
若楓
時(shí)間:
2025-5-21 20:59
標(biāo)題:
APT刀軌數(shù)據(jù)生成NC程序C++源代碼
APT刀軌數(shù)據(jù)生成NC程序C++源代碼,本功能僅作為技術(shù)交流研究之用,代碼,功能可能存在缺失。需自行編寫刀軌數(shù)據(jù)的讀取與處理。以下僅為部分代碼以下為頭文件部分源代碼
int EQ_is_equal (double s, double t);
! P+ ]3 g5 M% V K
int EQ_is_ge (double s, double t);
/ M3 \2 d, |- G4 {5 X% L6 v4 f6 h `
int EQ_is_gt (double s, double t);
' y4 G. C) v1 \6 X* }2 q
int EQ_is_le (double s, double t);
5 B& b& D( M. W+ `4 T& M# c. u
int EQ_is_lt (double s, double t);
/ v. S. m3 ]9 M$ B
int EQ_is_zero (double s);
0 R" ^1 T3 _# K3 B$ ^
//=============================================================
! I6 h: Y- Y( y
double ARCTAN1 (double y, double x );
& ]/ c- ^6 _5 W, p' U% y
//#=============================================================
9 Y8 h4 @9 r0 a. B+ M8 l
double ARCTAN2 (double y, double x );
8 [9 s' B# n' y6 ]% ^
//#=============================================================
+ b0 Y) o; L4 }! H6 o7 ^
double CheckConst ( double angle, double constvar );
9 ~3 V6 k* [0 h8 F
//#=============================================================
6 Y+ N, \) ?# c
double Check360 ( double angle );
; K- s* f, ?5 F+ ], `
//#=============================================================
( s4 `, i6 D0 R0 c( ?
double CheckLimit ( double angle, double kin_axis_min_limit, double kin_axis_max_limit );
+ X3 Y" K8 i- I- y5 T0 H; M4 \$ D
//#=============================================================
復(fù)制代碼
6 t% h8 ^( U. {+ Y1 F
以下為部分源代碼,用于判斷,計(jì)算角度等
* {7 W' G5 O( _. @% i" ]: ]4 E% e, H
int EQ_is_equal (double s, double t)
% y, I; {/ c$ @8 ~8 z8 e+ X
& c! }+ F+ X1 {$ |
{
9 s; [- i7 u4 n
8 g3 b) b" `9 h2 |
if (fabs(s-t)<= system_tolerance) { return(1); } else { return(0) ; }
. O* y8 W" R4 I* W, U
! d) I/ b$ I8 a1 \ z5 u5 @- }
}
. ~ e4 l1 V; `$ ~
3 P( D7 n( J a% ?+ n F) F
/***********************************************************************/
* B! s6 v* Y1 j/ ~6 S( w
5 m, u) g4 }8 o B; ]7 H" R6 Q
int EQ_is_ge (double s, double t)
! Q. I+ J* s+ e) E+ v
- u) @" o1 | ^7 {. c; B
{
7 u! B* l/ G# x$ n7 f
9 n* D5 T- f+ X8 t) J9 P/ z; M" }
if (s > (t - system_tolerance)) { return(1); } else { return(0) ; }
" {* `* @, J9 x" l V' E
_! x2 c* q) w( c' e3 u) O
}
1 |- z: W' o3 T) j- Y
1 Q& j, H5 ?6 ?6 L
/***********************************************************************/
" b2 w; w' p0 ]
4 x3 z1 O% R4 W9 A) {4 I
int EQ_is_gt (double s, double t)
2 I9 F6 e1 p: E+ o
9 B& ]% R9 \$ ~- i. K
{
- N5 ]$ B( n" C. M
]; ?: S1 h7 [* H- O T
if (s > (t + system_tolerance)) { return(1); } else { return(0) ; }
: h$ }: i9 K" B( s0 o) r6 h
+ B/ t# Z4 Y/ a7 H
}
9 u3 m* b- q f7 _1 @. D* [
" ^, @0 J/ T% L, l
/***********************************************************************/
% q8 G$ l, y% K5 J. @- N6 i
H& N% Z4 X# M- L0 C9 b1 C: f
int EQ_is_le (double s, double t)
; W2 a7 K E* V
4 e8 u4 l3 D3 d, t
{
4 u( V2 p" I9 t) B b3 ^7 Z, M2 y- ^
5 E2 G( \; N$ D7 M5 M
if (s < (t + system_tolerance)) { return(1); } else { return(0) ; }
5 x2 P% e, q1 r, z
( u) \9 k: A. W2 _
}
7 f( H& D' n- C* ]' G
8 J" h5 k9 Z0 w0 N: D- [) }$ r$ [; S- y
/***********************************************************************/
1 x( T3 a7 J# s3 b, d
6 N) Z0 ?, O% s" g9 S
int EQ_is_lt (double s, double t)
# _6 |6 s0 X) |8 g
, E! A! g+ i8 f# z$ V* O1 {% u
{
1 x; d8 L1 u. i& B0 L3 e8 o: R
' |) ~5 x* {6 c" K& d- ?
if (s < (t - system_tolerance)) { return(1); } else { return(0) ; }
. E" c( n& g# ?$ s( B
6 D) v; U$ D4 [6 ` l
}
k) Z- H8 y4 a- `& {8 D7 g
2 a# P2 J' ]& |
/***********************************************************************/
) i" s5 H4 O% @3 l; @7 n
3 N/ v- P+ j+ ?' M/ ~" G
int EQ_is_zero (double s)
: C# i/ [8 z, K0 w3 K9 a+ |8 x7 f
\+ a# f2 _9 d( w" Z% t
{
( V) d5 r6 d: B$ l6 W$ x
# A! E4 c) f) F( ~: {5 F3 |' q
if (fabs(s)<= system_tolerance) { return(1); } else { return(0) ; }
- i% x4 @) C7 b2 R* _! I! a
0 H/ p% a; {' {& [
}
( a0 L$ a8 ]- w- q8 n* e. o
4 R5 `' x" I) Q) u
//=============================================================
! j4 D! d3 w8 T. a( d+ a
" x3 n8 ~/ b0 P
double ARCTAN1 (double y, double x )
5 e! v9 `% Q \
: M9 y; H( e6 n0 m) j
//#=============================================================
1 }- |6 c% a5 ^7 x; Y" p% c
# H. H6 E# i4 K' j: D H
{
) Y$ O/ b, P S* Q) V" J6 x
0 q$ d1 Q! H6 b: F) u2 Y6 B' n
double ang;
, L8 h) X3 c& r3 l/ V
5 E/ N/ \: ~* p0 ?
if (EQ_is_zero(y)) { y=0; }
6 n( j X8 E9 o) |
+ R" a# H4 @- _! ?( c
if (EQ_is_zero(x)) { x=0; }
/ s1 N2 w1 d# ?4 Z& r# l
, f" Q2 `3 f3 p) K; S
if (y == 0 && x == 0) { return(0); }
" ~, n& s& Y; ^' Z( h" J4 ]
8 u3 [: j' X' I! E
ang=atan2(y,x);
' A: X6 R4 P1 G4 ]3 w3 Y' a q y* w
; T! U0 u+ P1 N+ f
if (ang < 0 ) {
% B" D2 Z' Q& D1 B
& g! ?' O Z( B" }' K
return(ang + PI*2);
( O+ \ s, H: E& b1 j N( C
8 I1 {; B$ Q1 K/ ^; D! S
}
6 Y7 \0 M2 g6 f7 T+ ~! J) a' S4 e
8 Y& B s3 s. H, c! ]( }: f3 `8 z
return(ang);
# O3 P& \- T7 W2 N0 F
, t$ q: \! Y+ S/ j
}
* }6 Y: \8 h8 T* B8 b$ z/ H/ T
9 F2 Y8 ]. @0 j, o' ~. `" w; ]1 o) B
//#=============================================================
5 X) m# q, W8 r S* R2 h
9 I3 R' k3 L7 D- ^3 c i' s
double ARCTAN2 (double y, double x )
; T5 C# K, k: t4 v! P* X& M/ A, c
1 W& g3 _3 r7 X6 p' }- @
//#=============================================================
, o! r8 i# F, [, d/ `, m
+ |/ ?, z' _4 ]
{
* x- F1 d( Y/ r# w
3 R! g/ p1 H Q6 O$ c
double ang;
) k8 r3 o; P- M
8 h5 ?( D; O8 v) ^' T4 w! u" G
if (EQ_is_zero(y)) {
5 c8 f, m# k, M* x# V s
4 s+ I& G; B; h( o4 u# x3 @
if (x < 0.0) { return (PI); }
. [% Q3 T* z w* G0 y
5 Q% Z/ F" t! x6 x
return (0.0);
" l' f1 J1 h3 b
9 }- ]. l$ e5 p) m
}
, ?2 {$ q9 ~: }0 B+ H5 p6 H6 Y; k
( m( G- Y7 k: a3 h6 W$ o$ o
if (EQ_is_zero(x)) {
3 H3 _7 y' b5 Z$ b' |, k2 p8 ]/ Q
% h( h" \0 A; U0 ^2 z# d8 c$ k' R, \% o7 S
if (y < 0.0) { return(PI*1.5); }
9 y6 q, l! y( l0 g& u3 {
& Y9 p: I0 `3 W4 ^
return(PI*.5);
% G1 q1 F4 D4 @" q0 R
) ~3 i4 H, i5 w9 w4 J; [
}
. j* g$ s( g1 `4 I2 I
; A/ [4 ^$ U! R) V" u% |! q
ang=atan(y/x);
8 D/ j$ G/ g3 v; p5 y7 _+ Y! ^
/ [' n! b* P2 U3 O
if (x > 0.0 && y < 0.0) { return(ang+PI*2.0); }
( |- U7 z$ k. {/ x, `
! J9 x$ f% |+ c+ i+ c
if (x < 0.0 && y < 0.0) { return(ang+PI); }
' ^ [! t" t0 ^/ P1 |+ N' [
. w3 U- G7 p* z$ e. y+ h8 d
if (x < 0.0 && y > 0.0) { return(ang+PI); }
) i' S, i3 a7 e# d+ P' Q
2 ~9 T5 X4 i& Y5 \2 ^
return(ang);
1 n+ N8 L8 b' A9 y+ r6 n
W# ?6 [' f2 W, F+ E
}
* {& E [4 b6 s# m" q1 M
0 b% K) a( S- A4 b' a3 X+ K, S
//#=============================================================
& \, [/ Y8 p9 Q7 E4 Y' k F8 s; y3 d
5 F) ^% _2 b- u; I8 @
double CheckConst ( double angle, double constvar )
" G" ?% f& q# c( p! Q- D
8 y @$ H: ]" x) C
//#=============================================================
% f/ N# c# h! _3 g
7 I1 w# s7 n6 D* E0 a
{
( ?* F- K _( S: P/ j1 d0 u
4 P3 W) h# ?6 F" H2 M) S9 \1 ]* w
while (angle < -constvar) { angle+=constvar ; }
* h/ W7 g: C. {6 ^" u6 Z6 I( ?
1 X/ ~2 w; M6 p$ b: w" a' b5 B+ b
while (angle >= constvar) { angle-=constvar ; }
6 F: E( C' l; [7 i) ]3 m
$ S! p- p/ H" ~: C
return (angle) ;
& Z5 e6 V. h6 b
3 H, i) D8 j1 @9 `( K
}
" P; i( H' e+ D. Q2 O
6 K+ J5 o) Q( R) v# I
//#=============================================================
4 e* t* g! S: z, q! ^
( K7 z* g1 }/ H5 n
double Check360 ( double angle )
% ?7 ?7 Q5 J! `& [/ B, H0 L( g
0 e, t1 ]8 v& C% h9 B. j
//#=============================================================
) A( C1 o" H- y! ~3 j
6 Q5 X- ]# s: _6 a) Q
{
$ v4 V! `+ C% E5 w. A
/ g! p% H% C% d
while (angle < -360.) { angle+=360. ; }
, M4 O; J7 M# h1 Y* ^5 _
1 `' ^) b5 d9 l8 o y1 C) `
while (angle >= 360.) { angle-=360. ; }
# ]. g4 }' B; c- J
! w e& e6 b9 f" N7 l
return (angle) ;
! e- z* ?; M& `. Z4 D- N2 I+ `
& r5 R: {; j/ I/ C/ H- j
}
% E! E/ b9 z8 g
" U! x9 ]4 N& a2 K5 V9 ^
//#=============================================================
& @6 P" |# N( A5 R) n; ~
) c; I# H+ i K2 `
double CheckLimit ( double angle, double kin_axis_min_limit, double kin_axis_max_limit )
% a9 q8 o7 B1 c. t# V: h" P$ p
3 n- P8 B2 O/ H8 H8 D
//#=============================================================
4 c* U1 Y1 W" k/ ~; ?
! W& X$ I, o0 h- p6 Y4 L) H! c" M
{
: W# Q/ b! |; N0 N" b
6 h( g* X. {+ d% [9 J3 y$ L# t. Q
while ((angle-kin_axis_min_limit) > 360.) { angle-=360. ; }
$ Z1 N# ?" k0 h3 J
+ O; t0 a3 T9 u8 Z
while ((kin_axis_max_limit-angle) <= -360.) { angle+=360. ; }
7 w. @& W4 A- J' h1 F# `
2 k: U& U" y0 L4 F
return (angle) ;
7 W, l% N- v! T+ Q
: q, {* C6 Z! ^1 G" t( g# S
}
復(fù)制代碼
; a" e' A4 g2 R. h2 o$ ~
以下為搖籃5軸計(jì)算過程代碼
" T+ b, T5 \, k' {
i=sin(ang_rad[1]); j=0.0; k=cos(ang_rad[1]);
1 a, c/ ?7 s0 h8 D: x
5 n+ L% \8 p K
j=0.; B1=0.; B0=0.;
* p# j! J* k; E9 _4 P' Q
6 T: o2 U/ W* L; J
if (EQ_is_ge(i,0.)) {
# a+ @+ @: v" `
: L4 L- ]1 q6 v& t5 ~) M: A; {
if (EQ_is_gt(k,0.)) { B0=acos(k); B1=B0; } else { B0=acos(k); B1=B0; }
5 ?1 k3 G# I5 Q8 R/ y7 I/ p
+ `% w- E" R }+ K6 N
}
* G& w: v/ S# T5 q' ?( a" B. }. |8 v
8 K* s/ h3 B& l9 @8 G1 P( s, r
if (EQ_is_lt(i,0.)) {
' {. Y$ w. {1 S9 y: ?
& Z9 _2 p A$ f8 t
if (EQ_is_lt(k,0.)) {
0 A' }) s( E1 Q8 I
8 n# H8 l3 @4 W4 f
B0=atan(i/k); B1=B0+PI ;
3 O7 N; d! j. W z+ x
) R0 u8 }4 d- ^. n2 ]( B" C" ^7 r" I
} else {
/ x6 _+ d: |( F, S6 O4 @
9 b9 e; B5 j0 V
if (EQ_is_zero(k)) { B0=-PI/2. ; } else { B0=atan(i/k); }
' _+ _7 ]6 ^! @: w8 u! I4 x
' q- J G5 K% e$ X/ J8 z8 ]
B1=2.*PI+B0 ;
, m' D: h# P7 Y/ I4 H4 Z& z- Q) b
6 N1 I+ D* B0 o8 F7 ?! g
}
% l" _/ |6 e9 ` o$ W" K
% r [7 d9 f @" Q* E; ^
}
! h* i% }# x% |% w" @$ K
- I( o6 I; u4 g8 F; C2 g
if (EQ_is_ge(B1,0.)) B0=1.; else B0=-1. ;
& G8 |- S( P3 d9 z) o' {
. N: S5 Z* v: W/ a" T
B2=(-1.)*B0*(2*PI-fabs(B1));
- _0 E6 U1 u9 w+ E5 G
3 _4 w v2 z1 h4 {* x7 ^ Q* p
ang_rad[0]=0.; ang_rad[1]=B1; ang_rad[2]=0.;
* [3 {' m" U. y
( W0 ~7 o: u& v7 Q2 ~- Q
ang_rad[3]=0.; ang_rad[4]=B2; ang_rad[5]=0.;
復(fù)制代碼
1 e- J' o" L4 }) D
通過輸出的NC程序,反向輸出的刀軌數(shù)據(jù)與原始刀軌文件對(duì)比,其數(shù)據(jù)結(jié)果一致。
9 f9 W2 S4 l! v: P) B
& E- }/ m1 R2 [
(, 下載次數(shù): 5)
上傳
點(diǎn)擊文件名下載附件
: Y3 Q# X3 _, |+ U C% G2 m2 x
測(cè)試結(jié)果:
( y& B# D* ^( m9 V S; N
(, 下載次數(shù): 7)
上傳
點(diǎn)擊文件名下載附件
' b) P" @$ t5 r; P
2 E7 s8 c* T& p- S3 C _
反向測(cè)試結(jié)果
(, 下載次數(shù): 6)
上傳
點(diǎn)擊文件名下載附件
. O4 T- M- e \0 Q$ u: e* V1 i
作者:
yucammayco
時(shí)間:
2025-6-3 18:53
謝謝分享
歡迎光臨 若楓后處理論壇 (http://www.buddhismlove.com/)
Powered by Discuz! X3.5