cscの作法 その584

# 概要
cscの作法、調べてみた。
OpenRCF v2.8、見つけたので、windows11で、MSbuildしてみた。
Lidarを、調査してみた。

# 写真

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/18104/e5f39765-6b11-4889-b864-7eb6c3e51f0d.png)

# PointClundの比較

[0]は、コサイン
[1]は、サインに、見える。

|no|障害物有り[0]|障害物無し[0]|差|障害物有り[1]|障害物無し[1]|差|
|:-|:-|:-|:-|:-|:-|:-|
|0|-2.75|	-6|	3.25|	0|	0|	0|
|1|-2.75|	-5.992502|	3.242502|	-0.1376147|	-0.2998753|	0.1622606
|2|-2.75|	-5.970025|	3.220025|	-0.2759204|	-0.5990009	|0.3230805
|3|-2.75|	-5.932626|	3.182626|	-0.4156219|	-0.8966293	|0.4810074
|4|-2.75|	-5.880399|	3.130399|	-0.5574526	|-1.192016	|0.6345634
|5|-2.75|	-5.813474|	3.063474|	-0.7021904	|-1.484424	|0.7822336
|6|-2.75|	-5.732019|	2.982019|	-0.8506747	|-1.773121	|0.9224463
|7|-2.75|	-5.636236|	2.886236|	-1.003828	|-2.057386	|1.053558
|8|-2.75|	-5.526366|	2.776366|	-1.162681	|-2.33651	|1.173829
|9|-2.75|	-5.402682|	2.652682|	-1.328402	|-2.609794	|1.281392
|10|-5.265495|	-5.265495	|0	|-2.876554	|-2.876554	|0
|11|-5.115147|	-5.115147	|0	|-3.136124	|-3.136124	|0
|12|-4.952013|	-4.952013	|0	|-3.387855	|-3.387856	|1E-06
|13|-4.776503|	-4.776503	|0	|-3.631119	|-3.631119	|0
|14|-4.589053|	-4.589053	|0	|-3.865307	|-3.865307	|0
|15|-4.390133|	-4.390133	|0	|-4.089833	|-4.089833	|0
|16|-4.18024|	-4.18024	|0	|-4.304137	|-4.304137	|0
|17|-3.959899|	-3.959899	|0	|-4.507683	|-4.507683	|0
|18|-3.72966|	-3.72966	|0	|-4.699962	|-4.699962	|0
|19|-3.490098|	-3.490098	|0	|-4.880493	|-4.880493	|0
|20|-3.241814|	-3.241814	|0	|-5.048826	|-5.048826	|0
|21|-2.985426|	-2.985426	|0	|-5.20454	|-5.20454	|0
|22|-2.721576|	-2.721576	|0	|-5.347245	|-5.347245	|0
|23|-2.450924|	-2.450924	|0	|-5.476584	|-5.476584	|0
|24|-2.174146|	-2.174146	|0	|-5.592236	|-5.592236	|0
|25|-1.891934|	-1.891934	|0	|-5.693909	|-5.693909	|0
|26|-1.604993|	-1.604993	|0	|-5.78135	|-5.78135	|0
|27|-1.31404|	-1.31404	|0	|-5.854342	|-5.854342	|0
|28|-1.019802|	-1.019802	|0	|-5.9127	|-5.9127	|0
|29|-0.723016|	-0.723016	|0	|-5.95628	|-5.95628	|0
|30|-0.4244226|	-0.4244226	|0	|-5.984972	|-5.984972	|0
|31|-0.1247682|	-0.1247682	|0	|-5.998704	|-5.998704	|0
|32|0.1751979	|0.1751979	|0	|-5.997443	|-5.997443	|0
|33|0.4747262	|0.4747262	|0	|-5.981191	|-5.981191	|0
|34|0.7730679	|0.7730679	|0	|-5.94999	|-5.94999	|0
|35|1.069477	|1.069477	|0	|-5.903917	|-5.903917	|0
|36|1.363214	|1.363214	|0	|-5.843087	|-5.843087	|0
|37|1.653543	|1.653543	|0	|-5.767653	|-5.767653	|0
|38|1.939739	|1.939739	|0	|-5.677802	|-5.677802	|0
|39|2.221086	|2.221086	|0	|-5.57376	|-5.57376	|0
|40|2.496882	|2.496882	|0	|-5.455786	|-5.455786	|0
|41|2.766438	|2.766438	|0	|-5.324175	|-5.324175	|0
|42|3.029078	|3.029078	|0	|-5.179257	|-5.179257	|0
|43|3.284147	|3.284147	|0	|-5.021394	|-5.021394	|0
|44|3.531008	|3.531008	|0	|-4.85098	|-4.85098	|0
|45|3.769043	|3.769043	|0	|-4.66844	|-4.66844	|0
|46|3.997658	|3.997658	|0	|-4.474233	|-4.474233	|0
|47|4.21628	|4.21628	|0	|-4.268842	|-4.268842	|0
|48|4.424364|	4.424364	|0	|-4.052781	|-4.05278	|-1E-06
|49|4.621389|	4.621389	|0	|-3.82659	|-3.82659	|0
|50|4.806864|	4.806864	|0	|-3.590834	|-3.590834	|0
|51|4.980323|	4.980323	|0	|-3.346104	|-3.346104	|0
|52|5.141335|	5.141335	|0	|-3.09301	|-3.09301	|0
|53|2.75	|5.289495	|-2.539495	|-1.472448	|-2.832185	|1.359737
|54|2.75	|5.424435	|-2.674435	|-1.300001	|-2.564281	|1.26428
|55|2.75	|5.545816	|-2.795816	|-1.135524	|-2.289967	|1.154443
|56|2.75	|5.653336	|-2.903336	|-0.9777074	|-2.00993	|1.0322226
|57|2.75	|5.746725	|-2.996725	|-0.8254075	|-1.724869	|0.8994615
|58|2.75	|5.825751	|-3.075751	|-0.6776151	|-1.435497	|0.7578819
|59|2.75	|5.890215	|-3.140215	|-0.533423	|-1.142537	|0.609114
|60|2.75	|5.939957	|-3.189957	|-0.3920032	|-0.8467207	|0.4547175
|61|2.75	|5.974852	|-3.224852	|-0.2525868	|-0.5487881	|0.2962013
|62|2.75	|5.994813	|-3.244813	|-0.1144461	|-0.249485	|0.1350389
|63|2.75	|5.99979	|-3.24979	|0.02312049	|0.0504427	|-0.02732221
|64|2.75	|5.98977	|-3.23977	|0.1608028	|0.3502445	|-0.1894417
|65|2.75	|5.96478	|-3.21478	|0.2992933	|0.6491709	|-0.3498776
|66|2.75	|5.924881	|-3.174881	|0.4393005	|0.9464741	|-0.5071736
|67|2.75	|5.870173	|-3.120173	|0.5815642	|1.241411	|-0.6598468
|68|2.75	|5.800792	|-3.050792	|0.7268712	|1.533247	|-0.8063758
|69|2.75	|5.716912	|-2.966912	|0.8760736	|1.821249	|-0.9451754
|70|2.75	|5.618743	|-2.868743	|1.03011	|2.1047	|-1.07459
|71|2.75	|5.50653	|-2.75653	|1.190032	|2.38289	|-1.192858
|72|2.75	|5.380553	|-2.630553	|1.357033	|2.655123	|-1.29809
|73|5.241128	|5.241128	|0	|2.920721	|2.920721	|0
|74|5.088603	|5.088603	|0	|3.179018	|3.179018	|0
|75|4.923359	|4.923359	|0	|3.429369	|3.429369	|0
|76|4.745809	|4.745809	|0	|3.671149	|3.671148	|1E-06
|77|4.556397	|4.556397	|0	|3.903752	|3.903753	|-1E-06
|78|4.355596	|4.355596	|0	|4.126599	|4.126598	|1E-06
|79|4.143909	|4.143909	|0	|4.339131	|4.33913	|1E-06
|80|3.921864	|3.921864	|0	|4.540817	|4.540817	|0
|81|3.690016	|3.690016	|0	|4.731154	|4.731153	|1E-06
|82|3.448946	|3.448946	|0	|4.909665	|4.909666	|-1E-06
|83|3.199254	|3.199254	|0	|5.075904	|5.075905	|-1E-06
|84|2.941566	|2.941566	|0	|5.229457	|5.229456	|1E-06
|85|2.676526	|2.676526	|0	|5.369938	|5.369938	|0
|86|2.404796	|2.404796	|0	|5.496998	|5.496998	|0
|87|2.127055	|2.127055	|0	|5.610318	|5.610317	|1E-06
|88|1.843998	|1.843998	|0	|5.709615	|5.709616	|-1E-06
|89|1.556332	|1.556332	|0	|5.794641	|5.794641	|0
|90|1.264776	|1.264776	|0	|5.865183	|5.865183	|0
|91|0.970058	|0.970058	|0	|5.921066	|5.921066	|0
|92|0.6729157	|0.6729157	|0	|5.962149	|5.962149	|0
|93|0.3740915	|0.3740915	|0	|5.98833	|5.988329	|1E-06
|94|0.07433221	|0.07433221	|0	|5.999543	|5.999542	|1E-06
|95|-0.2256128	|-0.2256128	|0	|5.99576	|5.99576	|0
|96|-0.524994	|-0.524994	|0	|5.976991	|5.976992	|-1E-06
|97|-0.8230629	|-0.8230629	|0	|5.943283	|5.943283	|0
|98|-1.119075	|-1.119075	|0	|5.894719	|5.89472	|-1E-06
|99|-1.412289	|-1.412289	|0	|5.831422	|5.831423	|-1E-06
|100|-1.701974	|-1.701974	|0	|5.753549	|5.75355	|-1E-06
|101|-1.987404	|-1.987404	|0	|5.661295	|5.661295	|0
|102|-2.267867	|-2.267867	|0	|5.554891	|5.554892	|-1E-06
|103|-2.542662	|-2.542662	|0	|5.434603	|5.434603	|0
|104|-2.811101	|-2.811101	|0	|5.300731	|5.300732	|-1E-06
|105|-3.072514	|-3.072514	|0	|5.15361	|5.15361	|0
|106|-3.326248	|-3.326248	|0	|4.993608	|4.993608	|0
|107|-3.571667	|-3.571667	|0	|4.821124	|4.821123	|1E-06
|108|-3.808159	|-3.808159	|0	|4.63659	|4.636589	|1E-06
|109|-4.035133	|-4.035133	|0	|4.440466	|4.440466	|0
|110|-4.252021	|-4.252021	|0	|4.233244	|4.233244	|0
|111|-4.458282	|-4.458282	|0	|4.015441	|4.015442	|-1E-06
|112|-4.653398	|-4.653398	|0	|3.787602	|3.787601	|1E-06
|113|-4.836884	|-4.836884	|0	|3.550295	|3.550295	|0
|114|-5.008279	|-5.008279	|0	|3.304115	|3.304115	|0
|115|-5.167157	|-5.167157	|0	|3.049676	|3.049676	|0
|116|-2.75	|-5.31312	|2.56312	|1.442832	|2.787615	|-1.344783
|117|-2.75	|-5.445803	|2.695803	|1.271825	|2.518585	|-1.24676
|118|-2.75	|-5.564874	|2.814874	|1.108555	|2.243261	|-1.134706
|119|-2.75	|-5.670035	|2.920035	|0.9517413	|1.96233	|-1.0105887
|120|-2.75	|-5.761025	|3.011025	|0.8002669	|1.676494	|-0.8762271
|121|-2.75	|-5.837615	|3.087615	|0.6531408	|1.386467	|-0.7333262
|122|-2.75	|-5.899614	|3.149614	|0.509471	|1.092976	|-0.583505
|123|-2.75	|-5.946867	|3.196867	|0.3684406	|0.796752	|-0.4283114
|124|-2.75	|-5.979256	|3.229256	|0.2292886	|0.4985361	|-0.2692475
|125|-2.75	|-5.9967	|3.2467	|0.09129301	|0.1990757	|-0.10778269



# サンプルコード

```

using System;
using System.Windows;
using OpenRCF;
using Vector = OpenRCF.Vector;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;


namespace OpenRCF
{
	partial class MainWindow: Window {
		bool isMoved = false;

		LiDAR lidar1 = new LiDAR();
		Cuboid[] cuboids = new Cuboid[2];

		void Setup() {
			//Console.WriteLine(lidar1.StepAngle);//0.05
			//Console.WriteLine(lidar1.PointRadius);//0.02

			cuboids[0] = new Cuboid(0.5f, 3, 0.8f);
			cuboids[0].Position[0] = 3.0f;
			cuboids[0].Position[2] = 0.4f;

			cuboids[1] = new Cuboid(0.5f, 3, 0.8f);
			cuboids[1].Position[0] = -3.0f;
			cuboids[1].Position[2] = 0.4f;

			lidar1.Position.Follow(Keyboard.ShiftVector[0]);
			lidar1.Rotate.Follow(Keyboard.CtrlMatrix[0]);
			lidar1.Position[2] = 0.4f;

			Button1.Content = "start";
			Button2.Content = "stop";
			Button3.Content = "scan";
			Button4.Content = "none";
			Button5.Content = "none";
		}
		void Loop() {
			if (isMoved)
			{
				float[][] pointCloud = lidar1.PointCloud(cuboids);
				int pointNum = pointCloud.GetLength(0);
				//Console.WriteLine(pointNum);//126
				float[] point0 = pointCloud[0];
				//Console.WriteLine(point0.GetLength(0));//3
				float[] point1 = pointCloud[1];
				float[] point2 = pointCloud[2];
				int i;
				int j;
				for (i = 0; i < 126; i++)
				{
					Console.WriteLine(pointCloud[i][0]);
				}
			}
		}
		void Draw() {
			lidar1.Draw();
			cuboids[0].Draw();
			cuboids[1].Draw();
		}
		void Button1_Click(object sender, RoutedEventArgs e) {
			isMoved = true;
		}
		void Button2_Click(object sender, RoutedEventArgs e) {

			isMoved = false;
		}
		void Button3_Click(object sender, RoutedEventArgs e) {
			float[][] pointCloud = lidar1.PointCloud(cuboids);
			int i;
			for (i = 0; i < 126; i++)
			{
				Console.WriteLine(pointCloud[i][1]);
			}
		}
		void Button4_Click(object sender, RoutedEventArgs e) {
		}
		void Button5_Click(object sender, RoutedEventArgs e) {
		}
	}
}





```

以上。