Vector3.OrthoNormalize

jkjkbk·2023년 4월 24일
0

Unity

목록 보기
5/16

Vector3.OrthoNormalize

Declaration

public static void OrthoNormalize(ref Vector3 normal, ref Vector3 tangent, ref Vector3 binormal);

Parameters

Vector3 normal

normalized 됨

Vector3 tangent

normalized 되고 normal을 벡터로 하는 평면에 사상된 벡터값으로 변함

Vector3 binormal

normalized 되고 구해진 방향의 +,-를 제외한 값은 normal, tangent 에 의해 결정됨

Returns

없음. 넘겨 받은 매개변수들의 값을 바꿈.

Example

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class OrthoNormalize : MonoBehaviour
{
    public Vector3 Vector1;
    public Vector3 Vector2;
    public Vector3 Vector3;

    public Color color1;
    public Color color2;
    public Color color3;

    void Update() 
    {
        Debug.DrawRay(Vector3.zero, Vector1, Color.blue);
        Debug.DrawRay(Vector3.zero, Vector2, Color.red);
        Debug.DrawRay(Vector3.zero, Vector3, Color.green);

        Vector3 newVector1 = Vector1;
        Vector3 newVector2 = Vector2;
        Vector3 newVector3 = Vector3;

        Vector3.OrthoNormalize(ref newVector1, ref newVector2, ref newVector3);

        Debug.DrawRay(Vector3.zero, newVector1, color1);
        Debug.DrawRay(Vector3.zero, newVector2, color2);
        Debug.DrawRay(Vector3.zero, newVector3, color3);
    }
}


1. Vector1 은 normalized 되고 방향 유지
2. Vector2 는 normalized 되고 Vector1을 normal로 하는 평면에 사상된 벡터의 방향으로 변환됨
3. Vector3는 normalized 되고 Vector1와 변환된 Vector2에 수직인 방향이면서 원래의 방향이 Vector1과 변환된 Vector2에 대해 위쪽이므로 위쪽 방향 벡터로 됨

0개의 댓글