-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateLines.cs
More file actions
33 lines (27 loc) · 920 Bytes
/
CreateLines.cs
File metadata and controls
33 lines (27 loc) · 920 Bytes
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CreateLines : MonoBehaviour
{
Line L1;
Line L2;
// Start is called before the first frame update
void Start()
{
L1 = new Line(new Coords(0.0f, 0.0f, 0.0f), new Coords(-6.0f, 7.0f, 3.0f));
L1.Draw(1, Color.green);
L2 = new Line(new Coords(0.0f, 0.0f, 0.0f), new Coords(-7.0f, -6.0f, 6.0f));
L2.Draw(1, Color.red);
float intersectT = L1.IntersectsAt(L2);
float intersectS = L2.IntersectsAt(L1);
if (intersectT == intersectT && intersectS == intersectS)
{
GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
sphere.transform.position = L1.Lerp(intersectT).ToVector();
}
}
// Update is called once per frame
void Update()
{
}
}