# Class SimpleUnitCell

java.lang.Object
org.jmol.util.SimpleUnitCell

Direct Known Subclasses:
  `UnitCell`

public class SimpleUnitCell extends Object
general-purpose simple unit cell for calculations and as a super-class of unitcell, which is only part of Symmetry allows one-dimensional (polymer) and two-dimensional (slab) periodicity

## Field Summary

Fields
Modifier and Type
Field
Description
`protected float`
`a`
`protected double`
`a_`
`protected float`
`alpha`
`protected float`
`b`
`protected double`
`b_`
`protected float`
`beta`
`protected float`
`c`
`protected double`
`c_`
`protected double`
`cA_`
`protected double`
`cB_`
`protected double`
`cosAlpha`
`protected double`
`cosBeta`
`protected double`
`cosGamma`
`protected int`
`dimension`
`static final int`
`DIMENSION_TYPE_ALL`
`int`
`dimensionType`
0x07 : z,y,x periodic
`protected float`
`gamma`
`static final String`
`HEX_TO_RHOMB`
`static final int`
`INFO_A`
`static final int`
`INFO_ALPHA`
`static final int`
`INFO_B`
`static final int`
`INFO_BETA`
`static final int`
`INFO_C`
`static final int`
`INFO_DIMENSION_TYPE`
`static final int`
`INFO_DIMENSIONS`
`static final int`
`INFO_GAMMA`
`static final int`
`INFO_IS_HEXAGONAL`
`static final int`
`INFO_IS_RHOMBOHEDRAL`
`static final int`
`INFO_VOLUME`
`M4`
`matrixCartesianToFractional`
`protected M4`
`matrixCtoFNoOffset`
`M4`
`matrixFractionalToCartesian`
`protected M4`
`matrixFtoCNoOffset`
`static final int`
`PARAM_COUNT`
`static final int`
`PARAM_M33`
`static final int`
`PARAM_M4`
`static final int`
`PARAM_OXYZ`
`static final int`
`PARAM_SCALE`
`static final int`
`PARAM_SLOP`
`static final int`
`PARAM_STD`
`static final int`
`PARAM_SUPERCELL`
`static final int`
`PARAM_VAX`
`static final int`
`PARAM_VBX`
`static final int`
`PARAM_VCX`
`static final int`
`PARAM_VCZ`
`static final String`
`RHOMB_TO_HEX`
`protected double`
`sinAlpha`
`protected double`
`sinBeta`
`protected double`
`sinGamma`
`protected float`
`slop`
initial value is set in subclass UnitCell
`static final float`
`SLOP_PARAMS`
`static final float`
`SLOPDP`
`static final float`
`SLOPSP`
allowance for rounding in [0,1)
`protected static final double`
`toRadians`
`protected float[]`
`unitCellParams`
`double`
`volume`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`SimpleUnitCell()`

## Method Summary

Modifier and Type
Method
Description
`static void`
`addVectors(float[] params)`
`static boolean`
`approx0(float f)`
`static String`
`escapeMultiplier(T3 pt)`
Generally the multiplier is just {ijk ijk scale}, but when we have 1iiijjjkkk 1iiijjjkkk scale, floats lose kkk due to Java float precision issues so we use P4 {1iiijjjkkk 1iiijjjkkk scale, 1kkkkkk}
`static void`
`fillParams(V3 va, V3 vb, V3 vc, float[] p)`
`static int`
`getCellRange(T3 fset, P3[] cellRange)`
`static int`
`getDimensionFromParams(float[] params)`
Allows for abc, ab, or a
`P3`
`getFractionalOrigin()`
Get the fractional origin for the UccageRenderer.
`final float`
`getInfo(int infoType)`
`float`
`getInfoStr(String type)`
`float`
`getPrecision()`
`static T3[]`
`getReciprocal(T3[] abc, T3[] ret, float scale)`
Generate the reciprocal unit cell, scaled as desired
`final float[]`
`getUnitCellAsArray(boolean vectorsOnly)`
`final float[]`
`getUnitCellParams()`
`static void`
`ijkToPoint3f(int nnn, P3 cell, int offset, int kcode)`
Expanded cell notation: 111 - 1000 --> center 5,5,5; range 0 to 9 or -5 to +4 1000000 - 1999999 --> center 50,50,50; range 0 to 99 or -50 to +49 1000000000 - 1999999999 --> center 500, 500, 500; range 0 to 999 or -500 to +499 for example, a 3x3x3 block of 27 cells: {444 666 1} or {1494949 1515151 1} or {1499499499 1501501501 1}
`protected void`
`init(float[] params)`
`static boolean`
`isHexagonal(float[] params)`
`boolean`
`isPolymer()`
`static boolean`
`isRhombohedral(float[] params)`
`boolean`
`isSlab()`
`boolean`
`isSupercell()`
`static boolean`
`isValid(float[] parameters)`
`static SimpleUnitCell`
`newA(float[] params)`
`static float[]`
`newParams(float[] params, float slop)`
`static float`
`parseCalc(Viewer vwr, String s)`
`static float`
`parseCalcFunctions(Viewer vwr, String[] functions, String s)`
`static String`
`parseSimpleMath(Viewer vwr, String suvw)`
parse math such as "1/sqrt(3)" or "2sqrt(3) or "2cos(3pi/2)"
`static P4`
`ptToIJK(T3 pt, int scale)`
Convert user's {3 2 1} to {1500500500, 1503502501, 0 or 1, 1500501}
`static T3[]`
`setAbc(String abcabg, float[] params, T3[] ucnew)`
set cell vectors by string.
`static T3[]`
`setAbcFromParams(float[] params, T3[] ucnew)`
`static void`
`setMinMaxLatticeParameters(int dimension, P3i minXYZ, P3i maxXYZ, int kcode)`
`void`
`setPrecision(float slop)`
`final void`
`toCartesian(T3 pt, boolean ignoreOffset)`
`final void`
`toFractional(T3 pt, boolean ignoreOffset)`
`void`
`toFractionalM(M4 m)`
`String`
`toString()`
`P3`
`toSupercell(P3 fpt)`
convenience return only after changing fpt
`void`
`twelfthify(P3 pt)`
`int`
`twelfthsOf(float f)`
`void`
`unitizeDim(int dimension, T3 pt)`
Used for just about everything; via UnitCell including SpaceGroup.getSiteMultiplicity, Symmetry.getInvariantSymops, Symmetry.removeDuplicates, Symmetry.unitize, Symmetry.toUnitCell, SymmetryDesc.getTransform.
`static void`
`unitizeDimRnd(int dimension, T3 pt, float slop)`
Only used for getting equivalent points and checking for duplicates.
`static float`
`unitizeX(float x, float slop)`
`static float`
`unitizeXRnd(float x, float slop)`
Slightly higher precision -- only used for cmdAssignSpaceGroup checking for duplicates

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### PARAM_STD

public static final int PARAM_STD

See Also:
  - Constant Field Values

### PARAM_VAX

public static final int PARAM_VAX

See Also:
  - Constant Field Values

### PARAM_VBX

public static final int PARAM_VBX

See Also:
  - Constant Field Values

### PARAM_VCX

public static final int PARAM_VCX

See Also:
  - Constant Field Values

### PARAM_VCZ

public static final int PARAM_VCZ

See Also:
  - Constant Field Values

### PARAM_OXYZ

public static final int PARAM_OXYZ

See Also:
  - Constant Field Values

### PARAM_M4

public static final int PARAM_M4

See Also:
  - Constant Field Values

### PARAM_M33

public static final int PARAM_M33

See Also:
  - Constant Field Values

### PARAM_SUPERCELL

public static final int PARAM_SUPERCELL

See Also:
  - Constant Field Values

### PARAM_SCALE

public static final int PARAM_SCALE

See Also:
  - Constant Field Values

### PARAM_SLOP

public static final int PARAM_SLOP

See Also:
  - Constant Field Values

### PARAM_COUNT

public static final int PARAM_COUNT

See Also:
  - Constant Field Values

### INFO_VOLUME

public static final int INFO_VOLUME

See Also:
  - Constant Field Values

### INFO_IS_RHOMBOHEDRAL

public static final int INFO_IS_RHOMBOHEDRAL

See Also:
  - Constant Field Values

### INFO_IS_HEXAGONAL

public static final int INFO_IS_HEXAGONAL

See Also:
  - Constant Field Values

### INFO_DIMENSION_TYPE

public static final int INFO_DIMENSION_TYPE

See Also:
  - Constant Field Values

### INFO_DIMENSIONS

public static final int INFO_DIMENSIONS

See Also:
  - Constant Field Values

### INFO_GAMMA

public static final int INFO_GAMMA

See Also:
  - Constant Field Values

### INFO_BETA

public static final int INFO_BETA

See Also:
  - Constant Field Values

### INFO_ALPHA

public static final int INFO_ALPHA

See Also:
  - Constant Field Values

### INFO_C

public static final int INFO_C

See Also:
  - Constant Field Values

### INFO_B

public static final int INFO_B

See Also:
  - Constant Field Values

### INFO_A

public static final int INFO_A

See Also:
  - Constant Field Values

### DIMENSION_TYPE_ALL

public static final int DIMENSION_TYPE_ALL

See Also:
  - Constant Field Values

### HEX_TO_RHOMB

public static final String HEX_TO_RHOMB

See Also:
  - Constant Field Values

### RHOMB_TO_HEX

public static final String RHOMB_TO_HEX

See Also:
  - Constant Field Values

### toRadians

protected static final double toRadians

See Also:
  - Constant Field Values

### SLOPSP

public static final float SLOPSP
allowance for rounding in [0,1)

See Also:
  - Constant Field Values

### SLOPDP

public static final float SLOPDP

See Also:
  - Constant Field Values

### SLOP_PARAMS

public static final float SLOP_PARAMS

See Also:
  - Constant Field Values

### unitCellParams

protected float[] unitCellParams

### slop

protected float slop
initial value is set in subclass UnitCell

### matrixCartesianToFractional

public M4 matrixCartesianToFractional

### matrixFractionalToCartesian

public M4 matrixFractionalToCartesian

### matrixCtoFNoOffset

protected M4 matrixCtoFNoOffset

### matrixFtoCNoOffset

protected M4 matrixFtoCNoOffset

### volume

public double volume

### dimension

protected int dimension

### dimensionType

public int dimensionType
0x07 : z,y,x periodic

### a

protected float a

### b

protected float b

### c

protected float c

### alpha

protected float alpha

### beta

protected float beta

### gamma

protected float gamma

### cosAlpha

protected double cosAlpha

### sinAlpha

protected double sinAlpha

### cosBeta

protected double cosBeta

### sinBeta

protected double sinBeta

### cosGamma

protected double cosGamma

### sinGamma

protected double sinGamma

### cA_

protected double cA_

### cB_

protected double cB_

### a_

protected double a_

### b_

protected double b_

### c_

protected double c_

## Constructor Details

### SimpleUnitCell

protected SimpleUnitCell()

## Method Details

### getPrecision

public float getPrecision()

### setPrecision

public void setPrecision(float slop)

### isSupercell

public boolean isSupercell()

### isValid

public static boolean isValid(float[] parameters)

### newA

public static SimpleUnitCell newA(float[] params)

Parameters:
  `params` - len = 6 [a b c alpha beta gamma] len = 6 [a b -1 alpha beta gamma] // slab len = 6 [a -1 -1 alpha beta gamma] // polymer or len = 15 [-1 -1 -1 -1 -1 -1 va[3] vb[3] vc[3]] // vectors only or len = 15 [a -1 -1 -1 -1 -1 va[3] vb[3] vc[3]] // polymer, vectors only or len = 15 [a b -1 -1 -1 -1 va[3] vb[3] vc[3]] // slab, vectors only or len = 22 [a b c alpha beta gamma m00 m01 .. m33] // matrix included and/or len = 25 [...................... na nb nc] // supercell and/or len = 26 [...................... na nb nc scale] // scaled supercell and/or len = 27 [..................................... slop] // precision
Returns:
  a simple unit cell

### getDimensionFromParams

public static int getDimensionFromParams(float[] params)
Allows for abc, ab, or a

Parameters:
  `params` -
Returns:
  1, 2, or 3

### init

protected void init(float[] params)

### newParams

public static float[] newParams(float[] params, float slop)

### addVectors

public static void addVectors(float[] params)

### fillParams

public static void fillParams(V3 va, V3 vb, V3 vc, float[] p)

### getFractionalOrigin

public P3 getFractionalOrigin()
Get the fractional origin for the UccageRenderer. NOTE: This is NOT a copy

Returns:
  fractionalOrigin

### toSupercell

public P3 toSupercell(P3 fpt)
convenience return only after changing fpt

Parameters:
  `fpt` -
Returns:
  adjusted fpt

### toCartesian

public final void toCartesian(T3 pt, boolean ignoreOffset)

### toFractionalM

public void toFractionalM(M4 m)

### toFractional

public final void toFractional(T3 pt, boolean ignoreOffset)

### isPolymer

public boolean isPolymer()

### isSlab

public boolean isSlab()

### getUnitCellParams

public final float[] getUnitCellParams()

### getUnitCellAsArray

public final float[] getUnitCellAsArray(boolean vectorsOnly)

### getInfoStr

public float getInfoStr(String type)

### getInfo

public final float getInfo(int infoType)

### getReciprocal

public static T3[] getReciprocal(T3[] abc, T3[] ret, float scale)
Generate the reciprocal unit cell, scaled as desired

Parameters:
  `abc` - [a,b,c] or [o,a,b,c]
  `ret` -
  `scale` - 0 for 2pi, teneral reciprocal lattice
Returns:
  oabc

### setAbc

public static T3[] setAbc(String abcabg, float[] params, T3[] ucnew)
set cell vectors by string. Does not set origin.

Parameters:
  `abcabg` - "a=...,b=...,c=...,alpha=...,beta=..., gamma=..." or null
  `params` - to use if not null
  `ucnew` - to create and return; null if only to set params
Returns:
  T3[4] ucnew as [origin, a, b, c], with origin unchanged or {0 0 0}

### setAbcFromParams

public static T3[] setAbcFromParams(float[] params, T3[] ucnew)

### unitizeDim

public void unitizeDim(int dimension, T3 pt)
Used for just about everything; via UnitCell including SpaceGroup.getSiteMultiplicity, Symmetry.getInvariantSymops, Symmetry.removeDuplicates, Symmetry.unitize, Symmetry.toUnitCell, SymmetryDesc.getTransform. Low precision here unless SET HIGHPRECISION TRUE has been issued.

Parameters:
  `dimension` -
  `pt` -

### unitizeDimRnd

public static void unitizeDimRnd(int dimension, T3 pt, float slop)
Only used for getting equivalent points and checking for duplicates. Presumption here is that two points should not be close together regardless of lattice distances.

Parameters:
  `dimension` -
  `pt` -
  `slop` -

### unitizeX

public static float unitizeX(float x, float slop)

### unitizeXRnd

public static float unitizeXRnd(float x, float slop)
Slightly higher precision -- only used for cmdAssignSpaceGroup checking for duplicates

Parameters:
  `x` -
  `slop` -
Returns:
  rounded value +/-slop

### twelfthsOf

public int twelfthsOf(float f)

### twelfthify

public void twelfthify(P3 pt)

### ijkToPoint3f

public static void ijkToPoint3f(int nnn, P3 cell, int offset, int kcode)
Expanded cell notation: 111 - 1000 --> center 5,5,5; range 0 to 9 or -5 to +4 1000000 - 1999999 --> center 50,50,50; range 0 to 99 or -50 to +49 1000000000 - 1999999999 --> center 500, 500, 500; range 0 to 999 or -500 to +499 for example, a 3x3x3 block of 27 cells: {444 666 1} or {1494949 1515151 1} or {1499499499 1501501501 1}

Parameters:
  `nnn` -
  `cell` -
  `offset` - 0 or 1 typically; invalid input: '<' 0 means "apply no offset"
  `kcode` - Generally the multiplier is just {ijk ijk scale}, but when we have 1iiijjjkkk 1iiijjjkkk scale, floats lose kkk due to Java float precision issues so we use P4 {1iiijjjkkk 1iiijjjkkk scale, 1kkkkkk}. Here, our offset -- initially 0 or 1 from the uccage renderer, but later -500 or -499 -- tells us which code we are

### ptToIJK

public static P4 ptToIJK(T3 pt, int scale)
Convert user's {3 2 1} to {1500500500, 1503502501, 0 or 1, 1500501}

Parameters:
  `pt` -
  `scale` - 1 for block of unit cells; 0 for one large supercell
Returns:
  converted P4

### escapeMultiplier

public static String escapeMultiplier(T3 pt)
Generally the multiplier is just {ijk ijk scale}, but when we have 1iiijjjkkk 1iiijjjkkk scale, floats lose kkk due to Java float precision issues so we use P4 {1iiijjjkkk 1iiijjjkkk scale, 1kkkkkk}

Parameters:
  `pt` -
Returns:
  String representation for state

### setMinMaxLatticeParameters

public static void setMinMaxLatticeParameters(int dimension, P3i minXYZ, P3i maxXYZ, int kcode)

Parameters:
  `dimension` -
  `minXYZ` -
  `maxXYZ` -
  `kcode` - Generally the multiplier is just {ijk ijk scale}, but when we have 1iiijjjkkk 1iiijjjkkk scale, floats lose kkk due to Java float precision issues so we use P4 {1iiijjjkkk 1iiijjjkkk scale, 1kkkkkk}. Here, our offset -- initially 0 or 1 from the uccage renderer, but later -500 or -499 -- tells us which code we are looking at, the first one or the second one.

### isHexagonal

public static boolean isHexagonal(float[] params)

Parameters:
  `params` -
Returns:
  true if approximately hexagonal

### isRhombohedral

public static boolean isRhombohedral(float[] params)

Parameters:
  `params` -
Returns:
  true if approximately rhombohedral

### approx0

public static boolean approx0(float f)

Parameters:
  `f` -
Returns:
  true or false

### getCellRange

public static int getCellRange(T3 fset, P3[] cellRange)

### parseCalc

public static float parseCalc(Viewer vwr, String s)

### parseCalcFunctions

public static float parseCalcFunctions(Viewer vwr, String[] functions, String s)

Parameters:
  `vwr` -
  `functions` - may be null to not parse any functions
  `s` -
Returns:
  value of the evaluated function

### parseSimpleMath

public static String parseSimpleMath(Viewer vwr, String suvw)
parse math such as "1/sqrt(3)" or "2sqrt(3) or "2cos(3pi/2)"

Parameters:
  `vwr` -
  `suvw` -
Returns:
  suvw replacing functions with their values

### toString

public String toString()

Overrides:
  `toString` in class `Object`