summaryrefslogtreecommitdiff
path: root/cad/src/experimental/CoNTub/Minimol.java
blob: 7ef15035beda1c70941249a678d27f017dc58a3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import java.awt.Color;

class Minimol
{
	int nvert;
	pto3D miniverts[];
	String minietiqs[];
	String miniperss[];
	float minisizes[];
	Color minicolor[];
	int miniselec[];
	int miniconec[][];
	double xmin, xmax, ymin, ymax, zmin, zmax;

	  Minimol (int nv)
	{
		nvert = nv;
		miniverts = new pto3D[nvert];
		minietiqs = new String[nvert];
		miniperss = new String[nvert];
		minisizes = new float[nvert];
		  minicolor = new Color[nvert];
		  miniselec = new int[nvert];
		  miniconec = new int[nvert][10];
	}


	Minimol (MoleculaB mo)
	{
		//Creacion de una minimolecula rapida para manipulacion dentro de un visor 3D
		//A partir de una molecula compleja tipo MoleculaB
		nvert = mo.susatomos.size ();
		miniverts = new pto3D[nvert];
		minietiqs = new String[nvert];
		miniperss = new String[nvert];
		minisizes = new float[nvert];
		minicolor = new Color[nvert];
		miniselec = new int[nvert];
		miniconec = new int[nvert][10];
		for (int i = 0; i < nvert; i++) {
			Atomo at = (Atomo) mo.susatomos.get (i);
			miniverts[i] = new pto3D (at.vert.x, at.vert.y, at.vert.z);
			minietiqs[i] = at.etiq;
			miniperss[i] = at.pers;
			minisizes[i] = (float) at.r;
			minicolor[i] = at.color;
			miniselec[i] = 0;
			for (int j = 0; j < 10; j++)
				miniconec[i][j] = at.mconec[j];
		}
	}


	void vaciar ()
	{
	}

//void deseleccionar(){for (int i = 0; i<susatomos.size();i++) ((Atomo)susatomos.get(i)).selec=0; nselec=0;}
//HABRIA QUE PONER HERRAMIENTAS DE SELECCIONADO

	void girox (double th)
	{
		for (int i = 0; i < nvert; i++) {
			float ct = (float) Math.cos (th / 180 * Math.PI);
			float st = (float) Math.sin (th / 180 * Math.PI);
			miniverts[i].rgirox (ct, st);
	}}
	void giroy (double th)
	{
		for (int i = 0; i < nvert; i++) {
			float ct = (float) Math.cos (th / 180 * Math.PI);
			float st = (float) Math.sin (th / 180 * Math.PI);
			miniverts[i].rgiroy (ct, st);
	}}
	void giroz (double th)
	{
		for (int i = 0; i < nvert; i++) {
			float ct = (float) Math.cos (th / 180 * Math.PI);
			float st = (float) Math.sin (th / 180 * Math.PI);
			miniverts[i].rgiroz (ct, st);
	}}

	double getDim ()
	{
		double Dim = 0.01;
		for (int i = 0; i < nvert; i++) {
			for (int j = i + 1; j < nvert; j++) {
				pto3D v = miniverts[i];
				pto3D w = miniverts[j];
				double dist = v.dista (w);
				if (dist > Dim)
					Dim = dist;
			}
		}
		return Dim;
	}


	double distancia (int a, int b)
	{
		pto3D v = miniverts[a];
		pto3D w = miniverts[b];
		return v.dista (w);
	}

	double angulo (int a, int b, int c)	//OJO EN GRADOS
	{
		pto3D v = miniverts[a];
		pto3D w = miniverts[b];
		pto3D u = miniverts[c];
		return u.menos (w).angulocong (v.menos (w));
	}

	double dihedro (int a, int b, int c, int d)
	{
		pto3D v = miniverts[a];
		pto3D w = miniverts[b];
		pto3D u = miniverts[c];
		pto3D s = miniverts[d];
		pto3D v1 = v.menos (w);
		pto3D v2 = w.menos (u);
		pto3D v3 = s.menos (u);
		return v1.dihedrog (v2, v3);
	}			//OJO EN GRADOS


	int selecstatus (int i)
	{
		return miniselec[i];
	}
	void selecciona (int i, int status)
	{
		miniselec[i] = status;
	}
	void deselecciona ()
	{
		for (int i = 0; i < nvert; i++)
			miniselec[i] = 0;
	}

	Minimol clona ()
	{
		Minimol mmn = new Minimol (this.nvert);

		for (int i = 0; i < this.nvert; i++) {
			mmn.miniverts[i] = this.miniverts[i].clona ();
			mmn.minietiqs[i] = this.minietiqs[i];
			mmn.miniperss[i] = this.miniperss[i];
			mmn.minisizes[i] = this.minisizes[i];
			mmn.minicolor[i] = this.minicolor[i];
			mmn.miniselec[i] = this.miniselec[i];
			for (int j = 0; j < 10; j++)
				mmn.miniconec[i][j] = this.miniconec[i][j];

		}
		return mmn;
	}
	double getLejania ()
	{
		double lej = 0;
		if (nvert == 1)
			return 0;
		for (int i = 0; i < nvert; i++) {
			pto3D v = miniverts[i];
			pto3D c = new pto3D (0, 0, 0);
			double dist = v.dista (c);
			if (dist > lej)
				lej = dist;
		}
		return lej;
	}
}