Changeset 9a83ccd for libcfa/src


Ignore:
Timestamp:
Nov 11, 2019, 2:41:41 PM (5 years ago)
Author:
Dmitry Kobets <dkobets@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
44f41997
Parents:
8bbdfdd
git-author:
Dmitry Kobets <dkobets@…> (10/04/19 14:20:38)
git-committer:
Dmitry Kobets <dkobets@…> (11/11/19 14:41:41)
Message:

Add sout override for vec2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/vector.hfa

    r8bbdfdd r9a83ccd  
    11#pragma once
    2 #include <math.h>
    3 
     2#include "math.hfa"
     3#include <iostream.hfa>
    44
    55//---------------------- Vector Types ----------------------
    66// TODO: make generic, as per glm
     7
    78
    89struct vec2 {
     
    1011};
    1112
    12 //---------------------- Geometric Functions ----------------------
    13 // These functions implement the Geometric Functions section of GLSL
     13void ?{}( vec2 & v, float x, float y) {
     14    v.[x, y] = [x, y];
     15}
    1416
    15 static inline float dot(const vec2& v, const vec2& u) {
    16     return v.x * u.x + v.y * u.y;
     17forall( dtype ostype | ostream( ostype ) ) {
     18    ostype & ?|?( ostype & os, const vec2& v) with (v) {
     19        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     20        fmt( os, "<%g,%g>", x, y);
     21        return os;
     22    }
     23    void ?|?( ostype & os, const vec2 v ) {
     24        (ostype &)(os | v); ends( os );
     25    }
     26}
     27
     28vec2 ?-?(const vec2& u, const vec2& v) {
     29    return [u.x - v.x, u.y - v.y];
     30}
     31
     32/* //---------------------- Geometric Functions ---------------------- */
     33/* // These functions implement the Geometric Functions section of GLSL */
     34
     35static inline float dot(const vec2& u, const vec2& v) {
     36    return u.x * v.x + u.y * v.y;
    1737}
    1838
Note: See TracChangeset for help on using the changeset viewer.