Debian Codegraph @

src/dr/evomodel/continuous/BranchDirectionAttributeProvider.java

raw symbols SCIP
1 /*
2 * BranchDirectionAttributeProvider.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package dr.evomodel.continuous;
27
28 import dr.xml.*;
29
30 /*
31 * @author Marc Suchard
32 */
33 public class BranchDirectionAttributeProvider extends BivariateTraitBranchAttributeProvider {
34
35 public static final String DIRECTION_PROVIDER = "branchDirections";
36 public static String TRAIT_EXTENSION = ".angle";
37
38 public BranchDirectionAttributeProvider(SampledMultivariateTraitLikelihood traitLikelihood) {
39 super(traitLikelihood);
40 }
41
42 protected String extensionName() {
43 return TRAIT_EXTENSION;
44 }
45
46 protected double convert(double latValue, double longValue, double timeValue) {
47 double angle = Math.atan2(latValue,longValue);
48 if (angle < 0)
49 angle = 2*Math.PI + angle;
50 return angle;
51 }
52
53 public static XMLObjectParser PARSER = new AbstractXMLObjectParser() {
54
55 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
56
57 SampledMultivariateTraitLikelihood traitLikelihood = (SampledMultivariateTraitLikelihood)
58 xo.getChild(SampledMultivariateTraitLikelihood.class);
59
60 return new BranchDirectionAttributeProvider(traitLikelihood);
61 }
62
63 public XMLSyntaxRule[] getSyntaxRules() {
64 return new XMLSyntaxRule[] {
65 new ElementRule(SampledMultivariateTraitLikelihood.class),
66 };
67 }
68
69 public String getParserDescription() {
70 return null;
71 }
72
73 public Class getReturnType() {
74 return BivariateTraitBranchAttributeProvider.class;
75 }
76
77 public String getParserName() {
78 return DIRECTION_PROVIDER;
79 }
80 };
81
82 // public static void main(String[] arg) {
83 // double[] vector = {-10,1};
84 //
85 // double angle = convert(vector[0],vector[1]);
86 //
87 // System.err.println("vec: "+new Vector(vector));
88 // System.err.println("angle: "+angle);
89 // }
90
91 }