Fuze Arena Logo
  • Forum
  • Creations
    Catalogue Showcase
  • Help

refract()

Purpose

Find the refraction of a vector

Description

Find the refraction of a vector when it passes through a surface

Syntax

result = refract( incident, normal, ior )

Arguments

result resulting refraction vector { x, y, z, w }

incident incident vector { x, y, z, w }

normal normal vector orthoganal to the surface { x, y, z, w }

ior index of refraction of the material from which the surface is made

Example

centre = { gWidth() / 2, gHeight() / 2 }
dir = { 1, 1 }
ior = 0.5

loop
    clear()
    c = controls( 0 )
    ior += c.lx * 0.1
    refractedDir = refract( dir, { 0, -1 }, ior )
    box( 0, centre.y, gWidth(), centre.x, { 0, 0, 1, 0.2 }, false )
    line( { centre.x - 250 * refractedDir.x, centre.y - 250 * dir.y }, centre, white )
    line( centre, { centre.x + 250 * refractedDir.x, centre.y + 250 * refractedDir.y }, white )
    printAt( 0, 0, "Move left Joy-Con Control stick left or right to adjust index of refraction" )
    printAt( 0, 1, "Index of refraction: " + ior )
    update()
repeat

Associated Commands

cross(), dot(), length(), normalize(), reflect()

logo

©2019 FUZE Technologies Ltd. FUZE is a registered trademark of FUZE Technologies Ltd. All rights reserved.

Useful links

  • Fuze Main Site
  • Fuze Arena on Twitter
  • Fuze Arena on Youtube
  • Download Buyer

Contact Information

  • FUZE Technologies Ltd
    15 Clearfields Farm
    Wotton Underwood
    Aylesbury, Buckinghamshire
    ​England, HP18 0RS

  • +44 (0) 1844 239 432

  • contact@fuze.co.uk

© Copyright FUZE Technologies Ltd. All rights reserved.