Linker IT Software
Google
Web www.oraxcel.com
menubar-top-links menubar-top-rechts
Home Help Search Login
Welcome, Guest. Please Login.
SQL*XL: Database to Excel bridge litLIB: Excel power functions pack ExcelLock: Locking and securing your valuable Excel spreadsheets encOffice: Protect your Excel file easy and safe encOffice: Protect your Excel file easy and safe
Pages: 1
BondAngle Excel function (Read 1803 times)
Gerrit-Jan Linker
YaBB Administrator
*****




Posts: 75
BondAngle Excel function
29.10.08 at 21:13:55
 
BondAngle Excel function
 
To calculate a bond angle, an angle between 3 bonded atoms, is presented below. Input for the function are the cartesian coordinates of the 3 atoms:
 
=BondAngle(Atom1_X, Atom1_Y, Atom1_Z, Atom2_X, Atom2_Y, ... , Atom3_Z)
 

Public Function BondAngle(X1 As Double, Y1 As Double, Z1 As Double, X2 As Double, Y2 As Double, Z2 As Double, X3 As Double, Y3 As Double, Z3 As Double) As Double
    Const PI = 3.14159265358979
 
    Dim A(3) As Double
    Dim B(3) As Double
    Dim AB As Double
    Dim dA As Double
    Dim dB As Double
    Dim cosa As Double
    Dim rada As Double
    Dim dega As Double
    
    A(1) = X1 - X2
    A(2) = Y1 - Y2
    A(3) = Z1 - Z2
    B(1) = X3 - X2
    B(2) = Y3 - Y2
    B(3) = Z3 - Z2
    
    AB = A(1) * B(1) + A(2) * B(2) + A(3) * B(3)
    
    dA = (A(1) * A(1) + A(2) * A(2) + A(3) * A(3)) ^ 0.5
    dB = (B(1) * B(1) + B(2) * B(2) + B(3) * B(3)) ^ 0.5
    
    cosa = AB / (dA * dB)
    rada = WorksheetFunction.Acos(cosa)
    dega = rada * 180 / PI
    
    BondAngle = dega
    
End Function
Back to top
 
« Last Edit: 29.10.08 at 21:14:28 by Gerrit-Jan Linker »  

Gerrit-Jan Linker
Linker IT Software
Email WWW Gerrit-Jan Linker   IP Logged
Pages: 1