Files
VirtualChemistry.Demo/Scenes/SelfBond.cs
2024-07-10 16:16:34 +01:00

25 lines
886 B
C#

using System.Collections.Generic;
using Godot;
using VirtualChemistry.Demo.Concepts;
namespace VirtualChemistry.Demo.Scenes;
public partial class SelfBond : Bond2D
{
public override void BondUpdate()
{
Reindex();
List<Vector2> points = new();
Vector2 pcenter = new(30, 0);
pcenter = pcenter.Rotated((float)Index * Mathf.Pi * 2f / (float)Multi);
Vector2 center = AtomFrom.Position + new Vector2(32, 32) + pcenter;
Vector2 d = AtomFrom.Position + new Vector2(32, 32) - center;
for (int i = 0; i <= 24; i++)
points.Add(center + d.Rotated(i*Mathf.Pi*2/24));
BondTypeA.Position = points[12] + new Vector2(-20, 0);
BondTypeB.Position = points[12] + new Vector2(20, 0);
Points = points.ToArray();
BondTypeA.Text = BondFrom.BondType;
BondTypeB.Text = BondTo.BondType;
}
}