| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using o0;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using UnityEngine;
- public class TestLineRegression : MonoBehaviour
- {
- List<Vector2> coordsCS = new List<Vector2>();
- // Start is called before the first frame update
- void Start()
- {
- var scale = 2;
- for (int i = 0; i < 1; i++)
- {
- for (int j = 0; j < 100; j+= scale)
- {
- var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
- cube.transform.SetParent(transform, false);
- cube.transform.localScale = Vector3.one / 20;
- cube.transform.localPosition = new Vector3(i, j, 0);
- coordsCS.Add(Camera.main.WorldToScreenPoint(cube.transform.position));
- }
- }
- Debug.Log(coordsCS.Last());
- (double[], double[]) dataX;
- (double[], double[]) dataY;
- var index = new double[coordsCS.Count];
- var x = new double[coordsCS.Count];
- var y = new double[coordsCS.Count];
- for (int i = 0; i < coordsCS.Count; i++)
- {
- index[i] = i * scale;
- x[i] = coordsCS[i].x;
- y[i] = coordsCS[i].y;
- }
- dataX = (index, x);
- dataY = (index, y);
- "dataX.js".FileWriteString(dataX.ToJson(true));
- "dataY.js".FileWriteString(dataY.ToJson(true));
- }
- // Update is called once per frame
- void Update()
- {
- if (Input.GetButtonDown("Fire1"))
- {
- Vector3 mousePos = Input.mousePosition;
- {
- Debug.Log(mousePos);
- }
- }
- }
- }
|