Example #1
0
    // Start is called before the first frame update
    void Start()
    {
        lr_ = GetComponent <LineRenderer>();

        local_to_world_ = transform.localToWorldMatrix;

        X_ = Vector3.Normalize(X_);
        W_ = Vector3.Normalize(W_);

        /* Calculate and set the arc points */
        Vector3[] points = CalculateArc();
        lr_.positionCount = resolution_ + 1;
        lr_.SetPositions(points);
        lr_.startWidth = width;
        lr_.endWidth   = width;

        /* Set the angle text using one decimal */
        AngleText temp = GetComponentInChildren <AngleText>();

        temp.angle_degrees_ = ((angle_positive_) ? "" : "-") + angle_deg_.ToString("F1") + "\u00B0";

        /* Calculate the position of the text using the direction vectors and the radius */
        /* Multiply by a factor to extend the text a bit outside of the angle */
        Vector3 text_pos = (Vector3.Normalize(middle_arc_point_) * Radius_ * 1.8f);

        temp.GetComponent <RectTransform>().localPosition = text_pos;
    }
Example #2
0
    // Start is called before the first frame update
    void Start()
    {
        lr_ = GetComponent <LineRenderer>();

        local_to_world_ = transform.localToWorldMatrix;

        Vector3 text_direction = Vector3.Normalize(Vector3.Cross(atom1_.transform.position - atom2_.transform.position, transform.position - Camera.main.transform.position));

        /* Calculate and set the arc points */
        local_points_[0] = atom1_.transform.position - transform.position;
        local_points_[1] = atom2_.transform.position - transform.position;

        Vector3[] points = new Vector3[] { TransformToWorld(local_points_[0]), TransformToWorld(local_points_[1]) };
        lr_.positionCount = 2;
        lr_.SetPositions(points);
        lr_.startWidth = width;
        lr_.endWidth   = width;

        AngleText temp = GetComponentInChildren <AngleText>();

        temp.angle_degrees_ = Vector3.Distance(atom1_.transform.position, atom2_.transform.position).ToString("F3") + " nm";

        Vector3 text_pos = text_direction * 0.08f;

        temp.GetComponent <RectTransform>().localPosition = text_pos;
    }