//*************************************************************** // Copyright 2008 Centre For Advanced Spatial Analysis, UCL // // Author: Joel Dearden, University College London // // Contact: j.dearden@ucl.ac.uk // // Joel Dearden, // Centre for Advanced Spatial Analysis, // University College London, // 1-19 Torrington Place, // London, // WC1E 7HB // // // This file is part of PedTrace. // // PedTrace is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // PedTrace is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with PedTrace. If not, see . // //*************************************************************** using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; /// /// Summary description for PTLineBarrier /// namespace pedTrace { public class PTLineBarrier { private string fUUID; private PTPoint fPosition; private PTPoint fSideVector; private float fLength; private float fOrientation; //Z-axis rotation (radians from positive Y-axis) //clockwise direction = -ve rotation public PTPoint getPosition() { return fPosition; } public PTLineBarrier(string UUID, PTPoint p, float orientation, float length) { fUUID = UUID; fPosition = p; fLength = length; fOrientation = orientation; fSideVector = calculateSideVector(); } private PTPoint calculateSideVector() { //calculate front direction vector PTPoint frontVector = PTPoint.directionVector2D(fOrientation); //calculate local x-axis PTPoint sideVector = PTPoint.XAxisFromYAxis(frontVector); //normalise sideVector = PTPoint.normaliseVector(sideVector); //multiply by length sideVector = PTPoint.multiplyVectorByScalar(sideVector, fLength / 2); return sideVector; } public PTPoint getStartPoint() { //add vector to centre PTPoint startPoint = PTPoint.addVector(fPosition, fSideVector); //return position return startPoint; } public PTPoint getEndPoint() { //add vector to centre PTPoint startPoint = PTPoint.subtractVector(fPosition, fSideVector); //return position return startPoint; } } }