We want to control the direction of vector which is calculated by two vectors’ cross multiplication.
For example, forbid it move forwards X axis, we can make one vector (0, 1, 0).
The following test code will get the third vector which is vertical with (3, 1, 2), but Y value equal to zero.

#include <iostream>
#include "tool.h"
using namespace std;

int main(int, char *[])
{
    PointStruct v0( 0, 1, 0 );
    PointStruct p0( 3, 1, 2 );
    PointStruct ret = v0 ^ p0;
    ret.Unit();
    cout << ret << endl;
    return EXIT_SUCCESS;
}

we get:
PointStruct [0.5547, 0, -0.83205]

分类: Math

发表评论

电子邮件地址不会被公开。 必填项已用*标注