# Design considerations and structure of the CDA package

## Description of a cluster at the R level

A cluster describes the geometry of N particles in a list,

- `r` is a data.frame of 3 columns (x, y, z) and N rows

- `angles` is a data.frame of 3 columns (x, y, z) and N rows

- `sizes` is a data.frame of 3 columns (x, y, z) and N rows

## Polarisability

The principal values of the inverse polarisability tensor of every particle are passed in a matrix Beta, with 3N rows (1/\(\alpha_x\),1/\(\alpha_y\),1/\(\alpha_z\)) for N particles, and Nlambda columns.

This matrix is formed from the sizes of the cluster, and the material and medium properties.

## Functions at the R level

### Modelling spectra

- `circular_dichroism_spectrum`

- `dispersion_spectrum`

### Clusters

- `cluster_chain`

- `cluster_dimer`

- `cluster_dimer_end`

- `cluster_helix`

### Utilities

- `array_factor`

- `alpha_kuwata`

- `equal_angles`

- `equal_sizes`

- `helix`

- `inverse_polarizability`

- `La`

- `polarizability_ellipsoid`

### Visualisation

- `curve_povray`

- `particles_povray`

- `rgl.ellipsoid`

- rgl.ellipsoids

## Structure of the core C++ components

- A is a 3Nx3N complex matrix

- Adiag is a 3Nx3N complex matrix

- Beta is a 3NxNlambda complex matrix

## Functions at the C++ level

### Array

`array_factor` Dipole sum (truncated) for 2D square array

### CDA

- `incident_field` Calculate the incident field at each dipole location

- `block_diagonal` Construct the diagonal blocks of the interaction matrix

- `interaction_matrix` Construct the full interaction matrix

- `extinction` Calculate the extinction cross-section for multiple incident angles

- `absorption` Calculate the absorption cross-section for multiple incident angles

### CD

- `averaging` Performs full angular averaging for both circular polarisations

- `average_spectrum` Angular-average spectra for LCP and RCP polarisations

### Dispersion

- `multiple_incident_field` Incident field along multiple axes

- `dispersion` Angle-resolved cross-sections for multiple directions of incidence

- `dispersion_spectrum` Angle-resolved spectra for linear or circular polarisations

### Utils

- `euler` Euler rotation matrix

- `axis_rotation` Rotation matrix about a cartesian axis