Class: Vec3
Lua
C++
Edit

Vec3::Reflect

This method bounces this vector off a specified normal vector and returns the result.

Syntax

Parameter Description
normal surface normal to bounce the vector off of.

Returns

Returns the reflected vector.

Example

#include "UltraEngine.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    //The motion is pointing down and forward
    Vec3 motion = Vec3(0, -1, 1);

    //The ground is pointing up
    Vec3 ground = Vec3(0, 1, 0);

    //Calculate bounce angle
    Vec3 bounce = motion.Reflect(ground);

    //The bounce angle should be up and forward
    Print(String(bounce.x) + ", " + String(bounce.y) + ", " + String(bounce.z));

    return 0;
}
Copyright © 2024 Ultra Software.
All rights reserved.