source: trunk/gui/vizservers/nanovis/Vector4.cpp @ 455

Last change on this file since 455 was 226, checked in by mmc, 19 years ago
  • Added code for Wei's visualization server.
  • Fixed the energyLevels widget so that it doesn't barf when the user attempts to download its contents.
File size: 1.7 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 * Vector4.cpp: Vector4 class
4 *
5 * ======================================================================
6 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
7 *           Purdue Rendering and Perceptualization Lab (PURPL)
8 *
9 *  Copyright (c) 2004-2006  Purdue Research Foundation
10 *
11 *  See the file "license.terms" for information on usage and
12 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13 * ======================================================================
14 */
15#include <stdio.h>
16#include "Vector4.h"
17
18
19Vector4::Vector4(){}
20
21Vector4::Vector4(float _x, float _y, float _z, float _w){
22        x = _x;
23        y = _y;
24        z = _z;
25        w = _w;
26}
27
28Vector4::~Vector4(){}
29
30void Vector4::print(){
31        fprintf(stderr, "Vector4: (%.3f, %.3f, %.3f, %.3f)\n", x, y, z, w);
32}
33
34void Vector4::perspective_devide(){
35        x /= w;
36        y /= w;
37        z /= w;
38        w = 1.;
39}
40
41Vector4 Vector4::operator +(Vector4 &op2){
42        Vector4 ret;
43        ret.x = x + op2.x;
44        ret.y = y + op2.y;
45        ret.z = z + op2.z;
46        ret.w = w + op2.w;
47        return ret;
48}
49
50Vector4 Vector4::operator -(Vector4 &op2){
51        Vector4 ret;
52        ret.x = x - op2.x;
53        ret.y = y - op2.y;
54        ret.z = z - op2.z;
55        ret.w = w - op2.w;
56        return ret;
57}
58
59float Vector4::operator *(Vector4 &op2){
60        return x*op2.x +
61                   y*op2.y +
62                   z*op2.z +
63                   w*op2.w;
64}
65
66Vector4 Vector4::operator *(float op2){
67        Vector4 ret;
68        ret.x = x*op2;
69        ret.y = y*op2;
70        ret.z = z*op2;
71        ret.w = w*op2;
72        return ret;
73}
74
75Vector4 Vector4::operator /(float op2){
76        Vector4 ret;
77        ret.x = x/op2;
78        ret.y = y/op2;
79        ret.z = z/op2;
80        ret.w = w/op2;
81        return ret;
82}
83
84//assign
85void Vector4::operator <(Vector4 &op2){
86        x = op2.x;
87        y = op2.y;
88        z = op2.z;
89        w = op2.w;
90}
Note: See TracBrowser for help on using the repository browser.