# CODESYS中SM3_Math库中的向量运算

sySeDoC

## SMC_VECTOR3D

SMC_VECTOR3D是SM3_Math库中的3维向量数据结构，形式如下：

``````TYPE SMC_VECTOR3D :
STRUCT
dX:LREAL;
dY:LREAL;
dZ:LREAL;
END_STRUCT
END_TYPE``````

``````PROGRAM PLC_PRG
VAR
vDst: SM3M.SMC_Vector3D;
vLhs: SM3M.SMC_Vector3D:=(dX := 1, dY := 3, dZ := 5);
vRhs: SM3M.SMC_Vector3D:=(dX := 2, dY := 4, dZ := 6);
END_VAR``````

``SMC_V3_Add(vDst:= vDst, vLhs:= vLhs, vRhs:= vRhs);``

### SMC_V3_Angle (FUN)

``````PROGRAM PLC_PRG
VAR
v1: SM3M.SMC_Vector3D:=(dX := 1, dY := 0, dZ := 0);
v2: SM3M.SMC_Vector3D:=(dX := 0, dY := 1, dZ := 0);
angle: LREAL;
END_VAR``````

``angle:=SMC_V3_Angle(v1:= v1, v2:= v2);``

### SMC_V3_CloseRel (FUN)

``````PROGRAM PLC_PRG
VAR
a: SM3M.SMC_Vector3D:=(dX := 1, dY := 0, dZ := 0);
b: SM3M.SMC_Vector3D:=(dX := 0.99, dY := 0.01, dZ := 0);
result: BOOL;
END_VAR``````

``result:= SMC_V3_CloseRel(a:= a, b:= b, eps:= 0.1);``

### SMC_V3_Cross (FUN)

``````PROGRAM PLC_PRG
VAR
vDst: SM3M.SMC_Vector3D;
vLhs: SM3M.SMC_Vector3D:=(dX := 1, dY := 3, dZ := 5);
vRhs: SM3M.SMC_Vector3D:=(dX := 2, dY := 4, dZ := 6);
END_VAR``````

``SMC_V3_Sub(vDst:= vDst, vLhs:= vLhs, vRhs:= vRhs);``

### SMC_V3_DistE (FUN)

``````PROGRAM PLC_PRG
VAR
v0: SM3M.SMC_Vector3D:=(dX := 1, dY := 3, dZ := 5);
v1: SM3M.SMC_Vector3D:=(dX := 2, dY := 4, dZ := 6);
DistE:LREAL;
END_VAR``````

``DistE := SMC_V3_DistE(v0:= v0, v1:= v1);``

### SMC_V3_Dot (FUN)

``````PROGRAM PLC_PRG
VAR
v1: SM3M.SMC_Vector3D:=(dX := 1, dY := 3, dZ := 5);
v2: SM3M.SMC_Vector3D:=(dX := 2, dY := 4, dZ := 6);
Dot:LREAL;
END_VAR``````

``Dot := SMC_V3_Dot(v1:= v1, v2:= v2);``

### SMC_V3_DotSq (FUN)

``````PROGRAM PLC_PRG
VAR
v: SM3M.SMC_Vector3D:=(dX := 1, dY := 3, dZ := 5);
DotSq:LREAL;
END_VAR``````

``DotSq := SMC_V3_DotSq(v:= v);``

### SMC_V3_IsScalarMultiple

``````PROGRAM PLC_PRG
VAR
u: SM3M.SMC_Vector3D:=(dX := 1, dY := 3, dZ := 5);
v: SM3M.SMC_Vector3D:=(dX := 2, dY := 6, dZ := 9.9);
dEps:BOOL;
END_VAR``````

``dEps :=SMC_V3_IsScalarMultiple(u:= u, v:= v, dEps:= 0.1);``

### SMC_V3_Lint (FUN)

``````PROGRAM PLC_PRG
VAR
vDst: SM3M.SMC_Vector3D;
vLhs: SM3M.SMC_Vector3D:=(dX := 1, dY := 3, dZ := 5);
vRhs: SM3M.SMC_Vector3D:=(dX := 2, dY := 4, dZ := 6);
END_VAR``````

``SMC_V3_Lint(vDst:= vDst, vLhs:= vLhs, vRhs:= vRhs, lambda:= 0.1);``

``````PROGRAM PLC_PRG
VAR
vDst: SM3M.SMC_Vector3D;
vLhs: SM3M.SMC_Vector3D:=(dX := 1, dY := 3, dZ := 5);
vRhs: SM3M.SMC_Vector3D:=(dX := 2, dY := 4, dZ := 6);
END_VAR``````

``SMC_V3_MAdd(vDst:= vDst, vLhs:= vLhs, vRhs:= vRhs,d:=d);``

### SMC_V3_Max_Cmp (FUN)

``````PROGRAM PLC_PRG
VAR
vDst: SM3M.SMC_Vector3D;
vLhs: SM3M.SMC_Vector3D:=(dX := 1, dY := 3, dZ := 5);
vRhs: SM3M.SMC_Vector3D:=(dX := 3, dY := 5, dZ := 1);
END_VAR``````

``SMC_V3_Max_Cmp(vDst:= vDst, v0:= v0, v1:= v1);``

### SMC_V3_Min_Cmp (FUN)

``````PROGRAM PLC_PRG
VAR
vDst: SM3M.SMC_Vector3D;
vLhs: SM3M.SMC_Vector3D:=(dX := 1, dY := 3, dZ := 5);
vRhs: SM3M.SMC_Vector3D:=(dX := 3, dY := 5, dZ := 1);
d:LREAL:=2;
END_VAR``````

``SMC_V3_Min_Cmp(vDst:= vDst, v0:= v0, v1:= v1);``

### SMC_V3_Mult (FUN)

``````PROGRAM PLC_PRG
VAR
vDst: SM3M.SMC_Vector3D;
vSrc: SM3M.SMC_Vector3D:=(dX := 1, dY := 3, dZ := 5);
d: LREAL:=2;
END_VAR``````

``SMC_V3_Mult(vDst:= vDst, vSrc:= vSrc, d:= d);``

### SMC_V3_NormE (FUN)

``````PROGRAM PLC_PRG
VAR
v: SM3M.SMC_Vector3D:=(dX := 1, dY := 3, dZ := 5);
NormE: LREAL;
END_VAR``````

``NormE:=SMC_V3_NormE(v:= v);``

### SMC_V3_NormMax (FUN)

``````PROGRAM PLC_PRG
VAR
v: SM3M.SMC_Vector3D:=(dX := 1, dY := 3, dZ := 5);
NormMax: LREAL;
END_VAR``````

``NormMax:=SMC_V3_NormMax(v:= v);``

### SMC_V3_Serialize (FUN)

``````PROGRAM PLC_PRG
VAR
v: SM3M.SMC_Vector3D:=(dX := 1, dY := 3, dZ := 5);
stream: SM3M.SM0.OutStringStream;
result:BOOL;
END_VAR``````

``result:=SMC_V3_Serialize(stream:= stream, v:= v);``

### SMC_V3_Sub (FUN)

``````PROGRAM PLC_PRG
VAR
vDst: SM3M.SMC_Vector3D;
vLhs: SM3M.SMC_Vector3D:=(dX := 1, dY := 3, dZ := 5);
vRhs: SM3M.SMC_Vector3D:=(dX := 2, dY := 4, dZ := 6);
END_VAR``````

``SMC_V3_Sub(vDst:= vDst, vLhs:= vLhs, vRhs:= vRhs);``

1 声望
0 粉丝